Copied to clipboard

Flag this post as spam?

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


  • Mike 56 posts 88 karma points
    Aug 20, 2010 @ 21:58
    Mike
    0

    How to get custom node property?

    The below code actually works, but I'm trying to modify it so that it pulls in the value of the headline field, not the node name of the articles. I'm sure it's something simple, but I'm a bit new to XSLT.

    Each newsArticle node contains a field alias called headline


            <xsl:for-each select="umbraco.library:GetXmlNodeById(1087)/newsArticle [@isDoc]">
              <div class="recentNewsArticle">
                  <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
              </div>
           </xsl:for-each>

    Thanks for your assitance.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Aug 20, 2010 @ 22:00
    Matt Brailsford
    0

    Hey Mike,

    Try this

     <xsl:for-each select="umbraco.library:GetXmlNodeById(1087)/newsArticle [@isDoc]">
    <div class="recentNewsArticle">
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="headline"/></a>
    </div>
    </xsl:for-each>

    Matt

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 20, 2010 @ 23:07
    Kevon K. Hayes
    0

    Im trying to do the same thing.. if you would be willing to answer a few questions for me it would be great:

    1) Is 1087 the parent node of the news articles?
    2) Is "newsArticle" in "/newsArticle" the name of the parent node?
    3) Is "headline" the alias or name of the headline property?

  • Mike 56 posts 88 karma points
    Aug 20, 2010 @ 23:53
    Mike
    0

    LOL, thanks Matt. When I saw your solution, even before trying it, I gave it the old face palm. I had been trying every sort of syntax scenario except the obvious. But alas, it works, thank you!

     

    Kevon, here's your answers:

    1) Yes
    2) newsArticle is the alias of the document type for the actual article nodes (which reside directly beneath my news node)
    3) headline is the alias of the property, also defined in the document type

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 21, 2010 @ 00:45
    Kevon K. Hayes
    0

    Thanks for the answers...

    What if the parent node is a different doctype that the child nodes? e.g.

    NewsItemContainer (Parent)
     NewsItem(child)

    will the XSLT still work?

  • Mike 56 posts 88 karma points
    Aug 21, 2010 @ 00:50
    Mike
    0

    They're actually different document types in my example. I have a news doctype (my parent node) and newsArticle doctypes for my subnode.

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 21, 2010 @ 16:21
    Kevon K. Hayes
    0

    Thanks Mike,

    I appreciate the response.  I'll give it a go.

  • Kevon K. Hayes 255 posts 281 karma points
    Aug 21, 2010 @ 19:46
    Kevon K. Hayes
    0

    OK I git this semi-working...this is my node structure, beginning with the Menu Items node ignore DeptHome

    this is my XSLT:

    <xsl:template match="/">
    <ul class="menuItem">
      <xsl:for-each select="umbraco.library:GetXmlNodeById(1321)/corDeptMenuItem [@isDoc]">
               
        <li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></li>
               
      </xsl:for-each>
    </ul>
    </xsl:template>

    the only other thing I need to change is the URL.  It should grab the URL of the Item Link: Property which is a content picker. I would like the NiceURL of the Human Resources node selected in the content picker above and not the links of the Billing, Payments, and Purchasing nodes themselves.  Any direction appreciated.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Aug 21, 2010 @ 21:44
    Kim Andersen
    0

    Kevon, try changing your code to this:

    <xsl:for-each select="umbraco.library:GetXmlNodeById(1321)/corDeptMenuItem [@isDoc]">
               
       
    <li><a href="{umbraco.library:NiceUrl(./ItemLink)}"><xsl:value-of select="@nodeName"/></a></li>
               
    </xsl:for-each>

    You might wanna change ItemLink in my code to the alias of that property. When you do that I think it will work for you.

    /Kim A

  • Steve 472 posts 1216 karma points
    Jan 06, 2016 @ 16:41
    Steve
    0

    I know this is an old topic, but why is select='headline' not select='@headline'?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Jan 06, 2016 @ 16:45
    Dave Woestenborghs
    0

    Because headline is a actual xml element. You would use @headline when it's a attribute

    Dave

  • Steve 472 posts 1216 karma points
    Jan 06, 2016 @ 19:20
    Steve
    0

    How can you tell that it's an xml element or an attribute?

Please Sign in or register to post replies

Write your reply to:

Draft