Extending the core framework

Topics: General, XSLT
Jul 9, 2011 at 2:32 PM

Hi everyone,

In April, I had a requirement from one of my clients to be able to select whether a new page they create, will be part of the main menu, or a new, customized, tab navigation. This took me some time, but I eventually got it working. This morning, I decided to download the source code (revision 8173) so that I can start with phase 2 of their requirements, and found that my implementation of the previously mentioned extension no longer functions as expected.

Following the user story I originally worked off:

As an administrative user I would like the ability to specify whether a newly created page will appear as a tabbed link, under it's parent page. I need to be able to set the property during the first step, of the "Add New Page" workflow, within the administrative section.

To do this, I figured that I had to extend

Composite.Data.Types.IPage

with a new boolean property, that specifies whether a page should be a tabbed page or not. The requirements from C1 also stated that I make the property nullable, as pages had already been created, and they where not aware of this newly added property so this was done as well. I then figured that I needed to update the XML node output, to grab a reference of this new property, and after some searching the system, I found

Composite.Data.PageNode.ToString()

 

which kind of did what I expected.

With this done, I looked at how the system stores information and most importantly where. The Workflow services answered most of these questions, and I ended up, updating both of the following:

 

Composite.Plugins.Elements.ElementProvider.PageElementProvider.AddNewPageWorkflow.stepInitialize_CodeActivity_ExecuteCode(object, EventArgs)

 

to include the default value for the new property

newPage.Property = false;

Secondly, I had to cater for the edit of a page as well, and found the following line:

Composite.Plugins.Elements.ElementProvider.PageElementProvider.EditPageWorkflow.saveCodeActivity_ExecuteCode(object, EventArgs)

to set the originalPage.Property = selectedPage.Property;

I updated the localization XML document to include the copy for the Label, Help, TrueLabel and FalseLabel and made the necessary updates to include the BooleanSelector in both Step1 and edit.

This is currently still working on the code from April but I cannot get the property to appear in the output:

<in:inputs xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
	<!-- Function Call Result (28 ms), XPath /in:inputs/in:result[@name='SitemapXml']/Page -->
	<in:result name="SitemapXml">
		<Page Id="a3055286-0e90-4b04-99dd-fb1a61dde0bf" Title="Home" MenuTitle="Home" UrlTitle="Home" Description="" ChangedDate="2011-05-13T03:34:35.063-05:00" ChangedBy="admin" URL="/Home.aspx?dataScope=administrated" FolderPath="/Home" Depth="1" isopen="true" iscurrent="true" xmlns=""/>
	</in:result>
</in:inputs>

Page should contain the property in the output stream, so I can access it within my XSL. For purpose of demo, let's call this property 'IsPageTab' but it's not appearing. I've followed the steps noted above to the Tee as per my original amendment, but I cannot get this to work.

I found an XML document within the application, which shows all published / unpublished pages, within in this output, I can see "IsPageTab" but I cannot see in the XML function out put above.

Any help would be appreciated.

Thanks.

Eric

Coordinator
Jul 11, 2011 at 9:32 AM

Hi Eric

In order to make it a part of SitemapXml, you should also edit method Composite.Core.WebClient.Renderings.Page.PageStructureInfo.BuildMap(), it has code

                    XElement pageElement = new XElement("Page",
                         new XAttribute("Id", page.Id),
                         new XAttribute("Title", page.Title),
                         (string.IsNullOrEmpty(page.MenuTitle) ? null : new XAttribute("MenuTitle", page.MenuTitle)),
                         new XAttribute("UrlTitle", page.UrlTitle),
                         new XAttribute("Description", page.Description),
                         new XAttribute("ChangedDate", page.ChangeDate),
                         new XAttribute("ChangedBy", page.ChangedBy ?? string.Empty));

add a new attribute here, and it should work.

 

However, I should say that you took the "hard" way of implementing that functionality. If you used  page meta data functionality instead, you would spend much less time doing changes and you wouldn't have to have custom changes in Composite.dll.

Nov 24, 2011 at 6:44 AM
Edited Nov 24, 2011 at 11:33 AM

Hi napernik,

I eventually had time to play around with your recommendation to use page meta data.

My question now is, how do I determine if a page has a valid page meta element assigned to it? The administrators of the system are not technical, and I can't expect them to add meta data to the page whenever they create a new page, thus the reason why I wanted to updated the composite assemblies, to have this feature I require built into the system by default

Update

figure this one out myself. you're right, much simpler if you understand meta data. thank you.