|Number of votes:||0|
Page Provider – Part three
Mapping your data to properties on the episerverpage is a fairly simple process. In the GetLocalPage method we simple use the SetValue on our created PageData object.
The standard page has two properties called MainBody and SecondaryBody so let’s set some values on those properties.
This works well for simple string based properties (both MainBody and SecondaryBody are of type xhtml string). So let’s try to work with a more complex property type, for instance the link collection. To do this we start with adding a property of that type called Links to our standard page page type.
To get a feel for how this works let’s start with just setting the property to some string value and see what happens.
This leads to the exception System.ArgumentException: Passed object must be of type LinkItemCollection. So apparently we need to create a LinkItemCollection and map it to the property data.
This is a somewhat unlikely scenario (to create the links programmatically that is). A more likely task is that the customer wants to add additional info to their data. Say for instance that the customer wants to add some links to their products that they for some reason don’t want or are unable to store in their product database.
What we’d do then is to give the page provider the capabilities to edit the page and when the user saves the page we save the property value of the link collection to some repository and then build logic to fetch the same data on the loading of the page (GetLocalPage).
This is what we’ll explore in the next post.
Please login to comment.