Copied to clipboard

Flag this post as spam?

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


  • James 4 posts 24 karma points
    Apr 11, 2012 @ 15:09
    James
    0

    Display Data Type name as heading

    Hi,

    I am looking for a way to display the data type name as a heading.

    <xsl:variable name="dataTypeId" select="/macro/dataTypeId"/>
      <xsl:variable name="dataType" select="umbraco.library:GetPreValues($dataTypeId)"/> 
     
      <h3>####Data Type name here###</h3>
        <ul
          <xsl:for-each select="$dataType//preValue">
          <li>
          <a>
            <xsl:value-of select="current()"/>
          </a>
          </li>
        </xsl:for-each>
        </ul>

    You can see from the code above I have some XSLT that displays a set of clickable links from a custom datatype checkbox.

    The data type ID is passed in by a macro parameter. This in turn is then used to get the data type prevalue.

    I can get the prevalues to display fine, but I'm a bit stuck as I want to display the data type name in the h3 tags.

    Any help would be greatly appreciated!

    Many Thanks!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 11, 2012 @ 17:05
    Lee Kelleher
    0

    Hi James, welcome to Our Umbraco!

    There aren't any helper methods out-of-the-box that will get you the data-type's name. To be honest, since data-types are intended to be reusable across doc-types, it is unusual to want to display their name on the front-end of a website.

    Regardless, we are here to help! :-)

    If you install the uComponents package there is a helpful XSLT extension called: "ucomponents.cms:GetDataTypeById" which you can pass in the data-type Id and get back XML about it.

    <xsl:variable name="dataTypeId" select="/macro/dataTypeId"/>
    <xsl:variable name="dataTypeXml" select="ucomponents.cms:GetDataTypeById($dataTypeId)" />
    <xsl:variable name="dataType" select="umbraco.library:GetPreValues($dataTypeId)"/>
    
    <h3>
     <xsl:value-of select="$dataTypeXml/@Name"/>
    </h3>
    <ul>
        <xsl:for-each select="$dataType//preValue">
            <li>
                <a>
                    <xsl:value-of select="text()"/>
                </a>
            </li>
        </xsl:for-each>
    </ul>

    More documentation about the uComponents XsltExtensions can be found here: http://ucomponents.codeplex.com/wikipage?title=CMS&referringTitle=Documentation

    Cheers, Lee.

  • James 4 posts 24 karma points
    Apr 11, 2012 @ 17:45
    James
    0

    Hey Lee,

    Thanks a lot! Just looked at the website, and there seems a lot of useful methods etc in there. Didn't even know it existed, only started with Umbraco last week!

    Thanks again,

    James

     

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Apr 11, 2012 @ 17:50
    Lee Kelleher
    0

    Hi James,

    You're welcome... there are a lot of goodies in uComponents - it is all community contributed code.  We are planning to get some of the good stuff into Umbraco itself!

    In the meantime, any questions, just ask!

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft