Try our conversational search powered by Generative AI!

Creating variables that can be uesd on multiple pages

Vote:
 

I would like to have some variables that are settable in one place by an editor that can then be used by other editors on multiple page types and then viewed by users as pages with the variables replaced by their values.  For instance, I have a commission percentage 10% that I want to use on 30 pages of the following page types: news pages, commission fee pages and sales recruiting pages.  I want one editor (perhaps an admin) to edit this percentage in a single place and change it to 12%.  When this change is approved (assuming there is an approval workflow for the commission value change), then all 30 pages will show the new 12% value. I will have different types of variables-text,integer, decimal,currency,date, date range and others.  The setting of the values of the variables will need some sort of UI.  For instance, if the variable is a date range there would be 2 calendar controls-one for the start date and one for the end date. How do I do this? Should I be trying to use dynamic properties, pagetypebuilder or something else? Please provide a short description on the steps required to do whichever method you recommend.

I also need to know what the user would have seen on any day because of US federal regulations (this is a financial site).  For example, today the change of the commission from 10%-12% was approved and yesterday I changed the language on a commission fee page from "The standard commission rate is x%" to "Your commission rate is x%". If I look at last week's version of the page it should show: "The standard commission rate is 10%".  If I look at today's version it should show:"Your commission rate is 12%".  In other words, views of past content should combine the static content of the page and the values of the dynamic content at that time.

 

TIA,

 

Steve Shier

#56074
Jan 03, 2012 18:32
Vote:
 

If the editors only need the values in "free" text you could use dynamic content. It allows the editor to insert property values from other pages and if the property is updated on the source page, it will be updated on all pages using that property.

If you want to have a history though, then you need to do something on your own. Maybe do a plugin to TinyMCE that inserts a certain code, and when to page is rendered you parse the output and change that code to the right output. If you want versioning it's gonna be some coding, but it shouldn't be impossible.

#56075
Jan 03, 2012 19:29
Vote:
 

Steve

You could store this kind of data on a single page - we use a siteSettings page for each of our sites with stuff like this in it. Changes to this page would be stored as history in the usual way.

You would then just use either the standard page property dynamic content - though I have had issues with this adding extra paragraphs - or you could code your own dynamic content control to do the job.

Michael.

#56090
Jan 04, 2012 15:52
Vote:
 

Thanks Erik and Michael. 

Erik, I expect your method would work.

Erik/Michael: I was able to create a simple page, add a standard property and access the value from another page.  I would probably need to make a TinyMCE modification like Erik has mentioned so I can display the archived page containing the variable correctly since the variable and page referencing it (the commissions fee page in my example) are archived separately out of the box in EPiServer.  When I change the variable value, it archives the previous version of that page with the previous value. The page referencing the value does not get a new version since it merely has a reference to a changing value and the reference pointer is unchanged.  Also, I would need to make the page containing the variable values only viewable by admins.

Michael: What is the siteSettings page? Is this just a custom page type you created? I see the My Settings page type in the AlloyTech sample solution which is user oriented but I expect you mean something different.

It would be nice to use dynamic properties that are not tied to a page instead of the approach above.  However, if I add a dynamic property to my install, I don't see where I would set the value other than doing it in code rather than in the admin interface which is where I need to do it.  I'd like to avoid creating a UI for setting dynamic property values if there is one already.  Right now, I go to Admin mode...Page Type and click Dynamic Properties and I create one (an integer with a name and help text) but there is no interface there for setting a value.  Does this value setting need to be done in code for dynamic properties or is there some other page for entering the value of a dynamic property?

Steve

#56099
Jan 04, 2012 20:19
Vote:
 

Hi Steve!

Regarding how editors set values to dynamic properties; take a look in the Editor´s manual. Go to page 15 and read about the dynamic properties. You can download the document here: http://world.episerver.com/Documentation/Items/Manuals/EPiServer-CMS/Editor-Manuals---EPiServer-CMS-6-R2-print/

Please note that dynamic property values are not included in the page version history. So in your case, where you need the history, dynamic properties are probably not the best solution.

/Klas

#56105
Jan 05, 2012 10:43
Vote:
 

Thanks Klas.  I see how to set values for these properties using the Edit Dynamic properties tool now thanks to you.   I like the idea of using them but without the versioning it would need to be customized to add it. 

I do notice that if using a standard property instead of a dynamic property on a "global variables" page I create, I need to go to the versions tab, then the compare tab and make sure the comparison type is "Changed fields" in order to compare the different values in the history of the page.  If comparison type is "With markup", the edit values are not visible even if there is content that references those variables. 

Instead of changing TinyMCE, it may be possible to customize the code by adding a new Comparison type called “Markup with properties substituted” and show the version of the page with the property value substituted in the content at the time of the content version selected.  Comparisons would compare pages with the property value substituted prior to the comparison.


Steve

#56123
Edited, Jan 06, 2012 14:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.