Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1287 posts 2744 karma points
    Sep 13, 2011 @ 03:51
    Amir Khan
    0

    Render content chosen with Content Picker

    Hi,

    I'm struggling a bit with a Content Picker. I can't seem to render content from a node chosen with the content picker, I can render the link to the document fine, but get nothing when trying to render any of the fields in the document type, any ideas what I'm doing wroing?

    Code below:

    <xsl:param name="currentPage"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="featuredArticle" select="/macro/featuredArticle"/>

    <xsl:template match="/">
            
            <!-- some output -->
            
            <!-- output link here, if there was a node picked: -->
            <xsl:apply-templates select="$currentPage/featuredArticle[normalize-space()]" />
            <!-- some more output -->

    </xsl:template>

    <!-- Template for link -->
    <xsl:template match="featuredArticle">
          <xsl:value-of select="articleTitle" disable-output-escaping="yes"/>
            <a href="{umbraco.library:NiceUrl(.)}">Link text</a>
    </xsl:template>

    Thanks!

    Amir

  • Amir Khan 1287 posts 2744 karma points
    Sep 13, 2011 @ 04:23
    Amir Khan
    0

    To clarify, my challenge is rendering the content of the selected source as opposed to one of its children...I'm sure I'm missing something fundamental here.

  • wolulcmit 357 posts 693 karma points
    Sep 13, 2011 @ 04:53
    wolulcmit
    0

    A content picker brings you an id, so what does the following give you?

    <xsl:apply-templatesselect="umbraco.library:GetXmlNodeById($featuredArticle)"/>"/>

    the following may also help
    http://our.umbraco.org/wiki/reference/umbracolibrary/getxmlnodebyid

  • Amir Khan 1287 posts 2744 karma points
    Sep 13, 2011 @ 05:53
    Amir Khan
    0

    Thank you for that step in the right direction! The code below worked great. Not sure if there was an advantage to using the format above? The normal for-each statement works fine with the exception of the int32 error in the validator.

    <xsl:for-each select="umbraco.library:GetXmlNodeById($currentPage/featuredArticle)">

    -Amir


Please Sign in or register to post replies

Write your reply to:

Draft