Copied to clipboard

Flag this post as spam?

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


  • Luke Johnson 61 posts 80 karma points
    Jul 05, 2011 @ 21:29
    Luke Johnson
    0

    Link page id's together to display the same content in more than one place

    I am looking for a way to link two or more pages (nodes) together so that by inputting content into one page, it will show up in other ones. For instance, I want to be able to input content into /about.aspx and have that content show up in /college/about.aspx or /highschool/about.aspx. Is XSLT the way to handle this?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 05, 2011 @ 22:55
    Chriztian Steinmeier
    0

    Hi Luke,

    You should have a look at the miscellaneous redirects/aliases that Umbraco provides out of the box, e.g. you could use a property called umbracoInternalRedirectId - you would set it on /college/about/ and /highschool/about/, both pointing to /about/ and Umbraco will take care of the rest.

    If you'd rather not have to create the extra pages, then you can use umbracoUrlAlias on the /about/ page, which will have the same end result.

    /Chriztian

     

  • Jules 276 posts 587 karma points
    Jul 07, 2011 @ 14:39
    Jules
    0

    I do a similar thing for a website footer whose content the user enters on the homepage node footer property but which appears for all other pages in the site as well (all other pages are based on a different document type and template).

    Basically you use the Umbraco library extenstion GetXmlNodeById in xslt to return the text entered for footer on the homepage.

    This of course should have an associated macro that you can use to render the same content on the other pages without having to define the same property (and reenter the text) in the other documnt types.

    Good luck

    Jules

     

    <?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:template match="/">
        <xsl:variable name="homeNode" select="umbraco.library:GetXmlNodeById(1051)"/>
        <xsl:value-of select="$homeNode/footerText"/>
    </xsl:template>
       
    </xsl:stylesheet>

     

  • Luke Johnson 61 posts 80 karma points
    Jul 08, 2011 @ 20:04
    Luke Johnson
    0

    This is working, but it is importing all the HTML markup along with the content.

    I am inserting the macro into the Rich Text editor, and I have the XSLT file pulling info based on a source retrieval (see below):

    <xsl:variable name="source" select="/macro/source"/>
    <xsl:variable name="homeNode" select="umbraco.library:GetXmlNodeById($source)"/>
    <xsl:value-of select="$homeNode/pageContent"/>

    This allows me to reuse the macro without having to have a different macro for every page. I thought that the HTML markup was being printed as text because the macro was calling the source node into a rich text editor. So I changed the data type to a text string, hoping that it would read the HTML rather than print it as text, but that didn't work.

    Is there a way to get the recieving page to read the markup? Or do I have to put the macro into a template?

    Thanks.

  • Luke Johnson 61 posts 80 karma points
    Jul 08, 2011 @ 23:14
    Luke Johnson
    0

    Update, I tried to fetch the node's content by using the Macro Container data type, but it is having the same result (HTML markup is printing as text rather than being parsed). 

    I created a tab into which I inserted the macro container. In my template I accessed the page field, 

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

    Then in the content area I went into the tab I created, and picked my node using the contentpicker in the macro. When the page loads, all the HTML markup comes mixed with the content:

    Am I missing something?

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 08, 2011 @ 23:36
    Chriztian Steinmeier
    0

    Hi Luke,

    Back to the macro from your previous post - you just need to set a flag in the value-of instruction:

    <xsl:variable name="source" select="/macro/source" />
    <xsl:variable name="homeNode" select="umbraco.library:GetXmlNodeById($source)" />
    <xsl:value-of select="$homeNode/pageContent" disable-output-escaping="yes" />

    Because the contents of the RichText editor is stored as plain text in the XML (or technically more correct, a "CDATA Section") - the XSLT processor can't process it as regular XML (big minus) - but the disable-output-escaping flag tells the processor to just output it "as is".  

    /Chriztian 

  • Luke Johnson 61 posts 80 karma points
    Jul 08, 2011 @ 23:43
    Luke Johnson
    0

    Thank-you, Chriztian! That was the piece I was missing. This works beautifully now!

Please Sign in or register to post replies

Write your reply to:

Draft