Hi all, i am trying to get the Preview function to work inthe Umbraco BackOffice. I am currently using umbraco 4.0.4.2 and was hoping someone could comment on what i am trying to do.
Bascially the preview function works for <umbraco:Item 's in the template files. In my XSLT and user controls it doesnt. I have created a variable and set its value to either a copy of the currentPage or it goes off to a custom xslt extension
Unfortunately we are running a Windows 2003 server with only .net2.0. I am trying to get us to upgrade to windows 2008 with .net4.0 but need an immediate solution.
I am having a bit of a problem in getting the trees to display in all sections. Can you give me a better idea of all the extar assemblies i need to include
Umbraco backoffice preview function
Hi all, i am trying to get the Preview function to work inthe Umbraco BackOffice. I am currently using umbraco 4.0.4.2 and was hoping someone could comment on what i am trying to do.
Bascially the preview function works for <umbraco:Item 's in the template files. In my XSLT and user controls it doesnt. I have created a variable and set its value to either a copy of the currentPage or it goes off to a custom xslt extension
<xsl:variable name="versionedPageRaw">
<xsl:choose>
<xsl:when test="string-length($umbVersion) != 0">
<xsl:copy-of select="WebFunctions:getVersionedPage($currentPage/@id)"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$currentPage"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="versionedPage" select="msxml:node-set($versionedPageRaw)/node" />
My getVersionedPage function is below and was hoping someone could let me know if there is anything wrong with what i am doing.
public static XPathNodeIterator getVersionedPage ( int rootNodeId )
{
XmlDocument xmlDoc = new XmlDocument ( );
XmlElement rootXmlNode = xmlDoc.CreateElement ( "node" );
xmlDoc.AppendChild ( getNodeRecursively ( rootNodeId, rootXmlNode, ref xmlDoc ) );
XPathNodeIterator myIterator = null;
myIterator = xmlDoc.CreateNavigator ( ).Select ( "/" );
return myIterator;
}
private static XmlElement createNodeNode ( XmlElement elemXmlNode, Document document )
{
elemXmlNode.SetAttribute ( "id", document.Id.ToString ( ) );
elemXmlNode.SetAttribute ( "version", document.Version.ToString ( ) );
try
{
if ( document.Parent != null )
elemXmlNode.SetAttribute ( "parentID", document.Parent.Id.ToString ( ) );
}
catch ( Exception ex )
{
elemXmlNode.SetAttribute ( "parentID", "-1" );
}
elemXmlNode.SetAttribute ( "level", document.Level.ToString ( ) );
elemXmlNode.SetAttribute ( "writerID", document.Writer.Id.ToString ( ) );
elemXmlNode.SetAttribute ( "creatorID", document.Creator.Id.ToString ( ) );
elemXmlNode.SetAttribute ( "nodeType", document.ContentType.Id.ToString() );
elemXmlNode.SetAttribute ( "template", document.Template.ToString ( ) );
elemXmlNode.SetAttribute ( "sortOrder", document.sortOrder.ToString ( ) );
elemXmlNode.SetAttribute ( "createDate", document.CreateDateTime.ToString ( "yyyy-MM-ddTHH:mm:ss" ) );
elemXmlNode.SetAttribute ( "updateDate", document.UpdateDate.ToString ( "yyyy-MM-ddTHH:mm:ss" ) );
elemXmlNode.SetAttribute ( "nodeName", document.Text );
elemXmlNode.SetAttribute ( "urlName", url.FormatUrl ( document.Text.ToLower ( ) ) );
elemXmlNode.SetAttribute ( "writerName", document.Writer.Name );
elemXmlNode.SetAttribute ( "creatorName", document.Creator.Name );
elemXmlNode.SetAttribute ( "nodeTypeAlias", document.ContentType.Alias );
elemXmlNode.SetAttribute ( "path", document.Path );
return elemXmlNode;
}
private static XmlElement createDataNode ( XmlElement elemDataNode, Property property )
{
try
{
elemDataNode.SetAttribute ( "alias", property.PropertyType.Alias );
elemDataNode.InnerText = ( property.Value.ToString ( ) );
}
catch ( Exception ex )
{
}
return elemDataNode;
}
private static XmlElement getNodeRecursively ( int nodeId, XmlElement thisXmlNode, ref XmlDocument xmlDoc )
{
Document document = new Document ( nodeId );
thisXmlNode = createNodeNode ( thisXmlNode, document );
foreach ( Property property in document.getProperties )
{
XmlElement xmlDataNode = xmlDoc.CreateElement ( "data" );
thisXmlNode.AppendChild ( createDataNode ( xmlDataNode, property ) );
}
try
{
if ( document.Children.Length > 0 )
{
foreach ( Document currentDocument in document.Children )
{
XmlElement childElemXmlNode = xmlDoc.CreateElement ( "node" );
childElemXmlNode = getNodeRecursively ( currentDocument.Id, childElemXmlNode, ref xmlDoc );
thisXmlNode.AppendChild ( childElemXmlNode );
}
}
}
catch ( Exception ex )
{
}
return thisXmlNode;
}
Missed out the umbVersion varibale ...
<xsl:variable name="umbVersion" select="umbraco.library:RequestQueryString('umbVersion')"/>
Why don't you upgrade to Umbraco 4.5.2, it has a built-in working preview.
Unfortunately we are running a Windows 2003 server with only .net2.0. I am trying to get us to upgrade to windows 2008 with .net4.0 but need an immediate solution.
Then use the .NET 3.5 version and bin deploy the .NET 3.5 assemblies (System.Core, System.Xml.Linq and a few others).
.NET 3.5 is CLR 2 still
Ok I wilol give this a go and update this post later on.
Thanks for your help Slace
I am having a bit of a problem in getting the trees to display in all sections. Can you give me a better idea of all the extar assemblies i need to include
Thanks
System.Web.Extensions, System.Web.Abstractions, you'll need them, can't think of any more.
Just install .NET 3.5, .NET 2.0 is pretty much EoL from MS anyway: http://support.microsoft.com/lifecycle/?LN=en-au&x=12&y=6&p1=8291
is working on a reply...