I'm not very good with XSLT, so I gave my shot at a Razor Example. It's relatively basic, but you can see how to get values from a pdcalendar (@alias=event) using Razor. I probably could have used a recursive helper function instead of the multiple loops and could use help doing that.... but all-in-all this will work and return a <ul> for every day for August 2012.
@{ //initiate the calendar var cal = new PDCalendar.library(); //get the events & their respective dates (use params...) System.Xml.XPath.XPathNodeIterator calIterator = cal.GenerateDates("8/1/2012", "8/31/2012", "event"); //print out the xml from pdcalendar //<p>@calIterator.Current.InnerXml</p> //create XML document and load it XmlDocument calXml = new XmlDocument(); calXml.LoadXml(@calIterator.Current.InnerXml); //first level: root -- 2nd level: node w/ date attrib -- 3rd level: event w/ node "id" <ul> @foreach (XmlNode child in calXml.ChildNodes) { foreach (XmlNode grandchild in child.ChildNodes) { @: <li>@grandchild.Attributes["date"].Value if (grandchild.ChildNodes.Count > 0) { @: <ul> foreach (XmlNode greatgrandchild in grandchild.ChildNodes) { @: <li> @: umbracoNodeId: @greatgrandchild.Attributes["id"].Value<br /> var calitem = @Model.NodeById(@greatgrandchild.Attributes["id"].Value); XmlDocument xmlpdc = new XmlDocument(); //my field alias is "event", but you can change below to whatever yours is... xmlpdc.LoadXml(@calitem.GetProperty("event").Value); XmlNode pdcroot = xmlpdc.DocumentElement; @: PDCstartdate: @pdcroot.SelectSingleNode("//pdcstart").LastChild.InnerText <br /> @: </li> } @: </ul> } @: </li> } } </ul> }
Razor example: PDCalendar
I'm not very good with XSLT, so I gave my shot at a Razor Example. It's relatively basic, but you can see how to get values from a pdcalendar (@alias=event) using Razor. I probably could have used a recursive helper function instead of the multiple loops and could use help doing that.... but all-in-all this will work and return a <ul> for every day for August 2012.
@inherits umbraco.MacroEngines.DynamicNodeContext
@using PDCalendar;
@using System.Xml;
@{
//initiate the calendar
var cal = new PDCalendar.library();
//get the events & their respective dates (use params...)
System.Xml.XPath.XPathNodeIterator calIterator = cal.GenerateDates("8/1/2012", "8/31/2012", "event");
//print out the xml from pdcalendar
//<p>@calIterator.Current.InnerXml</p>
//create XML document and load it
XmlDocument calXml = new XmlDocument();
calXml.LoadXml(@calIterator.Current.InnerXml);
//first level: root -- 2nd level: node w/ date attrib -- 3rd level: event w/ node "id"
<ul>
@foreach (XmlNode child in calXml.ChildNodes)
{
foreach (XmlNode grandchild in child.ChildNodes)
{
@: <li>@grandchild.Attributes["date"].Value
if (grandchild.ChildNodes.Count > 0)
{
@: <ul>
foreach (XmlNode greatgrandchild in grandchild.ChildNodes)
{
@: <li>
@: umbracoNodeId: @greatgrandchild.Attributes["id"].Value<br />
var calitem = @Model.NodeById(@greatgrandchild.Attributes["id"].Value);
XmlDocument xmlpdc = new XmlDocument();
//my field alias is "event", but you can change below to whatever yours is...
xmlpdc.LoadXml(@calitem.GetProperty("event").Value);
XmlNode pdcroot = xmlpdc.DocumentElement;
@: PDCstartdate: @pdcroot.SelectSingleNode("//pdcstart").LastChild.InnerText <br />
@: </li>
}
@: </ul>
}
@: </li>
}
}
</ul>
}
is working on a reply...