Copied to clipboard

Flag this post as spam?

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


  • montana 42 posts 63 karma points
    Aug 14, 2010 @ 01:12
    montana
    0

    XSLT output explicit content blocks outside of main site tree...

    total newb to umbraco, seems like a very well constructed system.I'm having a little bit of trouble in the outset here..

    Is there anyway to efficiently accomplish the following structure:

    <nav> [already done]

    <doc main body> [already done]

    <explicitly called content block1> [seemingly difficult to accomplish ?]

    <explicitly called content block2>

    <explicitly called content block3>

    I've created doctypes of contentBlock that sit at a sibling level to the site tree. The content block calls are where I'm finding some difficulty. Ive managed to get the $currentPage source from the root onwards, but when using the xpath to select explicit contentBlock nodes I get erratic [or no] results...

    I'm printing essentially the entire document tree with this:

        <xsl:template match="/">
            <xsl:for-each select="$currentPage/parent::*">
                <xsl:value-of select="."/>
            </xsl:for-each>
        </xsl:template>

    so I can see the root/contentBlock/contentBlock@nodeName='column' path I'm looking for....

    <root>

    ...

        <contentBlock id="1077" parentID="-1" level="1" writerID="1" creatorID="1" nodeType="1075" template="1076" sortOrder="3" createDate="2010-08-12T18:53:52" updateDate="2010-08-12T18:55:38" nodeName="contentBlocks" urlName="contentblocks" writerName="montana" creatorName="montana" path="-1,1077" isDoc="">
            <content></content>
            <contentBlock id="1078" parentID="1077" level="2" writerID="1" creatorID="1" nodeType="1075" template="1076" sortOrder="1" createDate="2010-08-12T18:54:47" updateDate="2010-08-13T14:28:10" nodeName="column" urlName="column" writerName="montana" creatorName="montana" path="-1,1077,1078" isDoc="">
                <content>
                    <p>content in column</p></content>
            </contentBlock>
        </contentBlock>
    </root>

    I'm trying to isolate the contentBlock @nodeName='column' and print it's child content node in order to create a standardized global medallion block that will persist throughout this particular template.

    my xpath / selector is failing miserably however...I've tried almost every possible iteration of the following I can think of that should work...

    This works but is woefully inefficient... pretty much every explicit path I've tried has failed however, eg /root/contentBlock/contentBlock

        <xsl:template match="/">
            <xsl:for-each select="$currentPage/parent::*">
                <xsl:value-of select="name()"/>
                <xsl:for-each select="descendant-or-self::* [@nodeName = 'column']">
                    <xsl:value-of select="name()"/>
                    :
                    <xsl:value-of select="."/>
                    <br />
                </xsl:for-each>
            </xsl:for-each>
        </xsl:template>


    Really what I want to do is super simple, and should work as follows:

        <xsl:template match="/root/contentBlock/contentBlock [@nodename='column']">

    I just don't quite know how to properly do that ^. any suggestions?

     

  • montana 42 posts 63 karma points
    Aug 14, 2010 @ 01:58
    montana
    0

    ah well I suppose I have to just use this:

        <xsl:template match="/">
            <xsl:for-each select="$currentPage/parent::*/child::contentBlock">
                <xsl:for-each select="descendant-or-self::* [@nodeName = 'column']">
                    <xsl:value-of select="."/>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:template>

    although it seems odd that reference to root with the exact path to the node I want doesn't seem to work...

    Edit: I wouldn't 'double post' but "editing" removes my xsl snippets! I had to re-add the code above since this RTE removes the code block... odd.

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 15, 2010 @ 00:17
    Chriztian Steinmeier
    0

    Hi montana,

    From what I can see, you're already well-versed in XSLT but you're just not familiar with the way Umbraco delivers the context. As soon as you get that, all your skills will do you good, and you'll enjoy writing lots of XSLT in Umbraco :-)

    I wrote about the XML context in Umbraco in this post: http://our.umbraco.org/forum/developers/xslt/11227-New-Schema-Select-Node-by-Id?p=0#comment41395

    Go get 'em!

    /Chriztian

  • montana 42 posts 63 karma points
    Aug 16, 2010 @ 21:08
    montana
    0

    that's exactly what I was looking for! perfect! many thanks for this. -it had been some years since I last looked at xslt so I'm a bit rusty.

    thanks for the hint about the umbraco.library call .. I was going the wrong direction.

Please Sign in or register to post replies

Write your reply to:

Draft