Not sure I understand completely.. you wish to check for the Header and MainBody property, if their not available display some other custom content?
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...
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
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.
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" ?
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 ?
Have you seen this?
http://blogs.interakting.co.uk/post/Property-Data-Injection-in-EPiServer.aspx
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();
try
{
while (stringUtils.extractBetween(ref s, "[", "]", ref index, out propName, true, true))
{
propValue = this.PropertyData.Parent[propName].ToString();
s = s.Insert(index, propValue);
}
}
catch
{
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();
target.Controls.Add(child);
base.CopyWebAttributes(target);
this.Controls.Add(target);
}
}
[Serializable]
[PageDefinitionTypePlugIn]
public class PropertyProxyFields : EPiServer.Core.PropertyString
{
public override IPropertyControl CreatePropertyControl()
{
return new PropertyProxyFieldsControl();
}
}
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