Copied to clipboard

Flag this post as spam?

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


  • Hundebol 167 posts 314 karma points
    Aug 26, 2009 @ 10:57
    Hundebol
    0

    Show output from Richtext Editor on subpage

    Hi,

    I am trying to reuse some content from a page, on another page.

    My tree looks like this

    Contact         (The page with the Richtext editor with the text that i want to reuse)
    -- Denmark   (The page where the text from the richtext editor (on the contact page) should show)

    I have almost gotten this to work: It outputs the text, but it does not output the text like it should. It does for instance not show links og image. But it should be able to, right? (Just like when you insert an item in a template.)

    My XSLT looks like this:

    <xsl:output method="html" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="1"/>
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:value-of select="umbraco.library:StripHtml(data [@alias = 'bodyText']) " />
    </xsl:for-each>
    </xsl:template>

    Hope that someone can point me in the right direction.

    Best regards,
    Brian

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 26, 2009 @ 11:26
    Dirk De Grave
    0

    Hi Brian,

     

    I'm not sure what StripHtml() really does, but I always use 

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

     

    Have you tried that one?

     

    Cheers,

    /Dirk

  • Hundebol 167 posts 314 karma points
    Aug 26, 2009 @ 11:34
    Hundebol
    0

    Hi Dirk,

     

    That worked. Can't believe i hadn't just tried that one! Da#n.

    A new problem arised though - i finds text and pictures from ALL the pages on the 1st level.

    Can i restrict to only the page it is supposed to get it from. (in this case Contact)

    br,
    Brian

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Aug 26, 2009 @ 11:55
    Dirk De Grave
    100

    Sure you can restrict that, just a matter of adjusting your for-each select, altho it doesn't make sense anymore to have that for-each in that case, does it? You'll only be selecting a single rte from a single child node...

    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level and @nodeTypeAlias = 'contact']/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <xsl:value-of select="umbraco.library:StripHtml(data [@alias = 'bodyText']) " />
    </xsl:for-each>

    In above snippet, I've added an extra restriction on type of page (assuming your Contact page is of 'contact' document type)

    But, as said, a for-each would become useless, and I think you'd better declare a variable first:

    <xsl:variable name="contactNode" select="$currentPage/node [@nodeTypeAlias = 'contact']"/>

    and use that variable in the xsl:value-of statement to get the text

    <xsl:value-of select="$contactNode/data [@alias = 'bodyText']"/>

     

    Cheers,

    /Dirk

     

  • Hundebol 167 posts 314 karma points
    Aug 26, 2009 @ 13:22
    Hundebol
    0

    Hi Dirk,

    With a little tweaking of your code it worked.

    My final code looks like this: (I changed the $currentPage/node in the variable to my own $currentPage/ancestor-or-self::node, from my old for-each)

    <xsl:output method="html" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:variable name="level" select="1"/>
    <xsl:variable name="contactNode" select="$currentPage/ancestor-or-self::node [@nodeTypeAlias = 'myContact']"/>
    <xsl:template match="/">
    <xsl:value-of select="$contactNode/data [@alias = 'rightColumn']" disable-output-escaping="yes"/>
    </xsl:template>


    Thanks for your help!

    best regards,
    Brian

Please Sign in or register to post replies

Write your reply to:

Draft