I’m looking for a way to display one piece of Umbraco content across multiple pieces of Umbraco content in Umbraco 4.9.
I’ve created a doc type called related link with 3 custom properties: h2 (textstring), body copy (richtext editor) and image (media picker). Using this doc type I want to create a piece of content I can place into multiple site pages from a single source so ongoing management of the content becomes easier.
Is this possible within Umbraco?
I’ve used the content picker to display the nodename of the related link content within a target page, but I can’t display the properties of the related link content within the target page.
I’ve had a look at razor macros and the ultimate picker but haven’t got anywhere as I’m not really a developer. It’s pretty critical to the site so I’m really hoping someone can help.
I used the first of your two answers and the content I was looking for has been placed into the page along with property aliases and the doc type. It's appearing the the page as below:
Is there any way to remove the aliases and the doc type info so it's only the content that's renderend to the page? Also, If I apply CSS styling to the original related link doc (eg: positioning the image relative to the text), can this styling be applied to the link properties when they're rendered in the target page? If not it shouldn't be a problem - just curious.
I also tried your second answer however was given the following error message when I tried to save the XSLT file:
The error code in detail is:
Error occured
Error in XSLT at line 17, char 12 15: <xsl:template match="/"> 16: 17: >>> <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/relatedContent2)/child::node()" mode="output"/><xsl:template match="*" mode="output"><xsl:value-of select="." disable-output-escaping="yes" /></xsl:template> <<< 18: 19:
To remove everything but content, just delete from <strong> to </strong> including the line between.
I don't know if you can reuse your original styling since I haven't seen your original markup.
Why you get the error in the 2nd example, puzzles me. I have no clue :) Have you tried to save the XSLT file with "Skip testing (ignore errors)" enabled ?
The reason for the last error ("Line 17, char 12") is not visible in the screenshot, but I can see from the errormessage what's wrong. The template (<xsl:template>...) that's at the end of that line needs to be moved out to the root level, as <xsl:template> elements can't be nested. So something like this instead:
Display properties through content picker
Hi.
I’m looking for a way to display one piece of Umbraco content across multiple pieces of Umbraco content in Umbraco 4.9.
I’ve created a doc type called related link with 3 custom properties: h2 (textstring), body copy (richtext editor) and image (media picker). Using this doc type I want to create a piece of content I can place into multiple site pages from a single source so ongoing management of the content becomes easier.
Is this possible within Umbraco?
I’ve used the content picker to display the nodename of the related link content within a target page, but I can’t display the properties of the related link content within the target page.
The XSLT I’m using to get the nodename is:
<xsl:template match="/"
<xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/data[@alias='relatedLinkText'])/@nodeName"/> </xsl:template>
I’ve had a look at razor macros and the ultimate picker but haven’t got anywhere as I’m not really a developer. It’s pretty critical to the site so I’m really hoping someone can help.
Thanks,
Chris
Hi
What version of Umbraco are you running and can you post the XML as well ?
Hi Sebastian,
I'm using v4.9.0.
The XSLT I've got is:
<?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" xmlns:twitter.library="urn:twitter.library" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch" xmlns:google.maps="urn:google.maps"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets twitter.library PS.XSLTsearch google.maps ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/relatedContent2)/@nodeName"/>
</xsl:template>
</xsl:stylesheet>
and on the template the macro shows as:
<umbraco:Macro Alias="RelatedContent2" runat="server"></umbraco:Macro>
That is showing the node name but none of the content inside the relevant document type. Can you help?
Hi
Try this.
It should return all child nodes to the ID stored in relatedContent2
In your original code, you're only asking for the @nodeName and nothing else.
You could replace
<xsl:value-of select="umbraco.library:GetXmlNodeById($currentPage/relatedContent2)/@nodeName"/>
with
<xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/relatedContent2)/child::node()" mode="output"/>
<xsl:template match="*" mode="output">
<xsl:value-of select="." disable-output-escaping="yes" />
</xsl:template>
Hi Sebastian,
Thanks so much for your help. :-)
I used the first of your two answers and the content I was looking for has been placed into the page along with property aliases and the doc type. It's appearing the the page as below:
Is there any way to remove the aliases and the doc type info so it's only the content that's renderend to the page? Also, If I apply CSS styling to the original related link doc (eg: positioning the image relative to the text), can this styling be applied to the link properties when they're rendered in the target page? If not it shouldn't be a problem - just curious.
Error occured
Error in XSLT at line 17, char 12
15: <xsl:template match="/">
16:
17: >>> <xsl:apply-templates select="umbraco.library:GetXmlNodeById($currentPage/relatedContent2)/child::node()" mode="output"/><xsl:template match="*" mode="output"><xsl:value-of select="." disable-output-escaping="yes" /></xsl:template> <<<
18:
19:
Thanks again for all your help.
Hi
To remove everything but content, just delete from <strong> to </strong> including the line between.
I don't know if you can reuse your original styling since I haven't seen your original markup.
Why you get the error in the 2nd example, puzzles me. I have no clue :)
Have you tried to save the XSLT file with "Skip testing (ignore errors)" enabled ?
Hi Trine/Sebastian,
The reason for the last error ("Line 17, char 12") is not visible in the screenshot, but I can see from the errormessage what's wrong. The template (<xsl:template>...) that's at the end of that line needs to be moved out to the root level, as <xsl:template> elements can't be nested. So something like this instead:
/Chriztian
Hi Chriz
Of course, my dear Watson ... :)
// Sebastian
That worked a treat!!
Thank you very much, both of you!
is working on a reply...