Copied to clipboard

Flag this post as spam?

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


  • mfeola 117 posts 221 karma points
    May 16, 2012 @ 19:45
    mfeola
    0

    General XSLT for display

    I have been trying to create a general XSLT to display all the content of the datatype by passing in the name of the field it uses in umbraco but so far it isn't displaying anything. 

    I don't really know what to do with this, i can pass in the name, i can pass in a field of a different datatype but i can't seem to pass in this data type and have the foreach loop run through all the parts of this field. what is wrong with this?

    <umbraco:Macro Field="[#list1]" Alias="CheckLists" runat="server"></umbraco:Macro>
    <umbraco:Macro Field="[#list2]" Alias="CheckLists" runat="server"></umbraco:Macro>
    
    <xsl:param name="ListField" select="/macro/Field"/>
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
      <div id="test">
        <xsl:for-each select="$ListField/data/item">
          <p><xsl:value-of select="listitem" /></p>
        </xsl:for-each>
      </div>
    </xsl:template>
  • mfeola 117 posts 221 karma points
    May 16, 2012 @ 20:51
    mfeola
    0

    and i do know that this foreach code WILL display the list items:

    <xsl:for-each select="$currentPage/Field/data/item">

    but that doesn't help when i have multiple embedded content fields on a single page and i want to just use one macro to display them all.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 16, 2012 @ 22:55
    Chriztian Steinmeier
    0

    Hi mfeola,

    To access an element by name (when you don't know the name beforehand) you can use the name() function:

    <xsl:for-each select="$currentPage/*[name() = $ListField]/data/item">
    ...
    </xsl:for-each>

    /Chriztian

  • mfeola 117 posts 221 karma points
    May 17, 2012 @ 16:56
    mfeola
    0

    that works perfectly, just had to change the macro from accepting the field to accepting the field name, thank you :D

Please Sign in or register to post replies

Write your reply to:

Draft