"Virtual" properties substituting e.g. MainBody on special pages


A recurring problem with pages typically holding data more than being articles is that functionality of list pages & search result pages, showing the site's "standard" page properties.

Now, if I have pages that do not have these properties at all, what would be the simplest way to make the pages show a "custom" header / text without actually implementing the Header & the MainBody fields ?

What I need is a readonly "MainBody" property that concatinates & formats data from different page properties. How ?

Regards, Bjørge

Jan 25, 2010 15:41

Not sure I understand completely.. you wish to check for the Header and MainBody property, if their not available display some other custom content?

Jan 25, 2010 20:52

Yes, by design all pages have MainBody and Heading properties. So far so good. What I don't think is a good design "twist", would be letting the search page know the internals of all kinds of pages it may display.

Hence, I would like my "special" page to have some kind of "virtual property" MainBody to render in listings other than the pages specially designed for the custom contents.

With CMS6 I could possibly use a custom property type with settings - to allow for runtime rendering via a template-like property type, like:

Property Name: MainBody

Property type: VirtualProperty

Property Settings: DisplayMask={AUTHORS}<BR /><B>{PUBLISHER}</B>, <I>{YEAR}</I>

Show in Editor: false

...so that this field would output a mix of specified fields with some formatting inbetween.

I like this idea, but I'd rather wait 'til CMS6 upgrade is due...

Jan 27, 2010 13:44

Well, it seems like the link is stored in table tblPageSoftlink - so it should be easy to retrieve. I guess ? ? ?

How do I retrieve a collection of pages having linked to a specific page ?

Regards, Bjørge

Edited, Jan 27, 2010 14:02

EPiServer.DataAbstraction.SoftLink.LoadReferencing finds links in inline content pointing to a specific page. The links are extracted during indexing so there is a small delay (default 1 minute) until this data surfaces if you don't change the indexing delay in web.config.

Jan 27, 2010 16:15

Thanks !

This sounds perfectly fine.

Is there a simple way to extract a set of pages being referenced, or do I have to do this the "hard way" ?

Jan 27, 2010 17:07

SoftLink.Load loads the what pages are being referenced.

Jan 27, 2010 17:52

Something went wrong with this thread, obviously, it was mixed with my other thread:


Property / content type for person-links

Well, the person-linking is now thoroughly explained. Jolly good.

Remaining is the "Virtual property" question, I'm really keen on hearing how others have solved this...

Anny suggestions ?

Jan 28, 2010 11:00

Have you seen this?



Jan 28, 2010 11:19

Yes, this was interesting !

I went down another route, though, I created a custom property type that looks for [PropertyName] and substitutes the named property with the actual property value found on the page. Example:

First name: [FirstName]<br>Last name: [Lastname]

....would render as:

First name: Bjørge

last name: Sæther

...and so far, this kind of works. On my development server. However, I can't get it to work on our web server.

The custom property type installs nice, I can get to define a property of the type in a page type, but when it is to be displayed, it simply displays the contents apparently not calling my overridden CreateDefaultFields().

Any ideas, anyone ?

Source code:

public class stringUtils : Object
        public static Boolean extractBetween(ref String s, String LeftD, String RightD, ref int index, out String Contents, Boolean doDelete, Boolean doDeleteDelimiters)
            int indexR;
            int lenDelimL = LeftD.Length;
            int lenDelimR = RightD.Length;
            index = s.IndexOf(LeftD, index);
            indexR = s.IndexOf(RightD, index + 1);
            if ((index >= 0) && (indexR >= 0))
                Contents = s.Substring(index + lenDelimL, indexR - (index + lenDelimL));
                if (doDeleteDelimiters)
                    s = s.Remove(index, (indexR - index) + lenDelimR);
                else if (doDelete)
                    s = s.Remove(index + lenDelimL, Contents.Length);
                    index += 1;
                return true;
            Contents = "";
            return false;

    public class PropertyProxyFieldsControl : PropertyStringControl
        private String _replaceFields()
            String propName = "";
            String propValue = "";
            int index = 0;
            String s = this.PropertyData.ToString();
                while (stringUtils.extractBetween(ref s, "[", "]", ref index, out propName, true, true))
                    propValue = this.PropertyData.Parent[propName].ToString();
                    s = s.Insert(index, propValue);
                s = " (Error: property [" + propName + "] not found)";
                return s;
            return s;

        public override void CreateDefaultControls()
            Panel target = new Panel();
            Literal child = new Literal();
            child.Text = this._replaceFields();

    public class PropertyProxyFields : EPiServer.Core.PropertyString
        public override IPropertyControl CreatePropertyControl()
            return new PropertyProxyFieldsControl();

Feb 11, 2010 15:15
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.