Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Yugeen Klimenko
Feb 8, 2011
  3295
(1 votes)

Common properties amongst the pages

Instead of using a lot of dynamic properties one can create a special settings page. On this page all site-wide settings are saved all together. Then you make only the name of this page to be a dynamic property (ref. to http://www.meadow.se/wordpress/?cat=12). This is a common solution. However, code in the code-behind files becomes a little more complicated if you want to retrieve the settings from the settings page.

For example:

PropertyCriteriaCollection

        propertyCriteriaCollection = new PropertyCriteriaCollection();

PropertyCriteria criteria = new PropertyCriteria();

criteria.Condition = CompareCondition.Equal;

criteria.Name = "PageTypeID";

criteria.Type = PropertyDataType.PageType;

criteria.Value = PageType.Load("SettingsPage").ID.ToString();

criteria.Required = true;

propertyCriteriaCollection.Add(criteria);

PageDataCollection pageDataCollection

                = DataFactory.Instance.FindPagesWithCriteria

                    (PageReference.RootPage, propertyCriteriaCollection);

if (pageDataCollection == null || pageDataCollection.Count == 0)

                return;

                      

if (pageDataCollection[0]["SomeProperty"] != null)

                TextBox1.Text =

                       pageDataCollection[0] ["SomeProperty"].ToString();

 

You see how many actions should be performed with a single aim – to get the SettingsPage’s SomeProperty value. Evidently it’s tiresome and error prone.

Instead you can force the page to load properties values from some other page. For this just open the Shortcut/External Link tab in edit mode, assign  “Fetch data from page in EPiServer CMS” to Link type , and choose the page the properties are loaded from (f.e. SettingsPage):

image

From this time you can apply to SettingsPage as if they belonged to the w1ef page:

string someProperty = CurrentPage["SomeProperty"] as string;

or:

<EPiServer:Property PropertyName="SomeProperty" runat="server" />

Feb 08, 2011

Comments

Feb 8, 2011 04:18 PM

What if you need both settings and data from another page? I like the PluginProperty approach:

[PlugInProperty(
Description = "PageTypeID: Start Page",
AdminControl = typeof(InputPageType),
AdminControlValue = "PageTypeID")]
public int StartPageTypeID { get; set; }

... and a singelton class to retrieve them.

Yugeen Klimenko
Yugeen Klimenko Feb 8, 2011 05:26 PM

Sure, it's suitable if you want to get data from one page (not more)

Yugeen Klimenko
Yugeen Klimenko Feb 9, 2011 09:46 AM

Sure, it's suitable if you want to get data from one page (not more)

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog