Copied to clipboard

Flag this post as spam?

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


  • Ole 3 posts 23 karma points
    Jul 07, 2010 @ 16:05
    Ole
    0

    One sidebar on multiple pages?

    Hi I started using Umbraco a week ago, and think it's great. There is one problem I'm having, it should be really easy, but I don't know how to do it in Umbraco. 

    I want to have a sidebar on the news pages. The content in it needs to stay the same, so the user don't have to add it to every news page. The sidebar is going to be updated often by the editor, using RTE.

    I'm stuck now, and I have no idea what to do. I thought if I could import content from a node(using RTE) into a macro, then import that macro into all the news pages, it would work. But I don't know how to do that, and there should be an easier way to do it.

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jul 07, 2010 @ 16:55
    Jan Skovgaard
    0

    Hi Ole

    It should be fairly easy to do this.

    In your master page for the news, you should really just place a macro that contains the content you want to have displayed.

    I'm asuming that the content in the sidebar will be edited from one node, somewehere in your content tree. Then it's a matter of using the GetXmlNodeById extension, which you can read more about in here http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid-%281%29

    I hope this makes sense and has given you an idea on how to achieve this? :-)

    /Jan

  • Ole 3 posts 23 karma points
    Jul 08, 2010 @ 10:10
    Ole
    0

    Thanks Jan.

    This is how my code ended up looking:

    <?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" 

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

     

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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->

    <!-- Sample with error handling if the node is not found -->

    <xsl:variable name="node" select="umbraco.library:GetXmlNodeById(1346)" />

    <xsl:choose>

            <xsl:when test="string($node/@id) = false()">

    The node could not be found

            </xsl:when>

            <xsl:otherwise>

    <xsl:value-of select="$node/data[@alias = 'innhold']" disable-output-escaping="yes"/><br />

            </xsl:otherwise>

    </xsl:choose>

    </xsl:template>

    </xsl:stylesheet>

    The bold text in the code is something I added, so it would read the node as HTML instead of just importing the text and tags. I imported the macro to the news template, so the editor don't have to add it for ever news item he creates.

    Ole.

Please Sign in or register to post replies

Write your reply to:

Draft