Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sophie Mitchell 23 posts 43 karma points
    Feb 03, 2012 @ 12:58
    Sophie Mitchell
    0

    Custom homepage - adding textpage details via xslt/macro

    Hello,

    Please could someone help me with my homepage that I'm trying to create.

    I would like to add the page title and summary from a specific textpage to my homepage. The idea being that my client can easily update the page summary when he has changes and they will then appear on the homepage. (Otherwise I would just add in html to the homepage itself).

    I thought I could get this to work using the logic I've used in my newslist page but as I'm trying to show the information from that specific page (rather than it's sub pages) nothing is displaying on the homepage.

    It's quite hard to explain so here's the xslt:

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>

    <xsl:stylesheet 

      version="1.0" 

      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 

      xmlns:msxml="urn:schemas-microsoft-com:xslt" 

      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" 

      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">

     

    <xsl:output method="xml" omit-xml-declaration="yes" />

     

    <xsl:param name="currentPage"/>

     

    <!-- Don't change this, but add a 'contentPicker' element to -->

    <!-- your macro with an alias named 'source' -->

    <xsl:variable name="source" select="/macro/source"/>

     

    <xsl:template match="/">

     

    <!-- The fun starts here -->

    <ul>

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">

      <li>

        <a href="{umbraco.library:NiceUrl(@id)}">

          <xsl:value-of select="@nodeName"/>

        </a>

        <p>

          <xsl:value-of select="summary"/>

        </p>

      </li>

    </xsl:for-each>

    </ul>

    </xsl:template>

    </xsl:stylesheet>

     

    Thank you in advance!

  • Rodion Novoselov 694 posts 859 karma points
    Feb 06, 2012 @ 09:03
    Rodion Novoselov
    0

    Hi. You don't need to create a new document for keeping just a homepage summary there. Just add yet another text property to your homepage document type, say, "Summary" with an alias "summary". Than you can place this property to your page template in the place you need with the markup:

    <summary>
       <umbraco:Item field="summary" runat="server" />
    </summary>

    I hope it's exactly what you meant.

  • Sophie Mitchell 23 posts 43 karma points
    Feb 06, 2012 @ 11:28
    Sophie Mitchell
    0

    Hi Rodion,

    Thanks - no that's not quite what I mean.

    I'd like to display the pagetitle, and the summary of sub page - on the homepage. I have the summary field etc in place on the sub page and just need to know how to get that to dynamically display on the homepage.

    Let me know if that doesn't make sense.

    Thanks 

  • Rodion Novoselov 694 posts 859 karma points
    Feb 06, 2012 @ 13:52
    Rodion Novoselov
    0

    Gut. Then you can create a new macro with a parameter, say, "Summary Page" (with the alias "summaryPage") of the type "Content Picker" and with Xslt like this:

    <!-- .... skipped ... -->
      <summary>
         <xsl:value-of select="umbraco.library:GetItem(/macro/summaryPage, 'summaryText')"/>
      </summary> 
    <!-- .... skipped ... -->

     

    Here: /macro/summaryPage will be resolved to the ID of the page selected by the content picker, and summaryText is assumed to be the name of the required property that contains the summary text.

  • Sophie Mitchell 23 posts 43 karma points
    Feb 06, 2012 @ 16:29
    Sophie Mitchell
    0

    Thanks.

    I created an xslt file called summarypage and it looks like this:

     <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="summaryPage" select="/macro/summaryPage"/>
        
    <xsl:template match="/">
     

    </xsl:template>

    </xsl:stylesheet>

    I tried to get the code <xsl:value-ofselect="umbraco.library:GetItem(/macro/summaryPage, 'summary')"/> in but it won't save. (summary is the name I have used rather than summary text).

    Here's the error:
    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging) 


    I saved it with this earlier <xsl:value-of select="summary"/> but nothing displayed on the homepage.

    My macro is called Summary Page and I have added the parameter summaryPage and selected content picker.

    Adding the macro to the homepage is all ok but not working because of the xslt.

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft