Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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.
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.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " ">]><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>
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?
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?
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".
Thank-you, Chriztian! That was the piece I was missing. This works beautifully now!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted