Copied to clipboard

Flag this post as spam?

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


  • Graeme Paul 44 posts 64 karma points
    Jul 15, 2011 @ 22:00
    Graeme Paul
    0

    filter by template name

    I was wondering if it is possible to filter by template name, I have done by doctype alias before but have a project coming up where this would be interesting to have.

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 15, 2011 @ 22:51
    Kim Andersen
    2

    Hi Graeme

    In the XML we don't have access to the template name, but only the template id. Don't know if this is enough for you or you need the template name.

    If you do need to grab the template name from a node you could take look at the GetTemplateById-extension in the uComponents package.

    I hope this can help you a bit.

    /Kim A

  • Rich Green 2246 posts 4008 karma points
    Jul 15, 2011 @ 23:12
    Rich Green
    1

    Important to note that (as Kim mentions) this information is not available in the XML, therefore you'll be hitting the database for every call.

    Rich

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 16, 2011 @ 09:27
    Lee Kelleher
    1

    After reading this topic, I reviewed the uComponents code for the GetTemplateAlias method (in Cms XsltExtensions) ... and found that I could improve it's performance significantly.  Seems that calling "Template.GetTemplate" uses a cached object, whereas I was previously using "new Template" which hits the database directly.

    Latest code changes are committed (CodePlex link) ... these will be part of the v2.2 (RTM) release.

    Cheers, Lee.

  • MarkD 5 posts 26 karma points
    Jul 16, 2011 @ 13:33
    MarkD
    1

    Hi,

    I'm porobably way of course here, but I know you can do something like this, where you can produce results based on the TemplateNodeId (which you can see from hovering over the template and looking at the Javascript result in yout browser status bar):

    So for eaxmple: the template node ID for my "News" template is "1223",

       <xsl:if test="@template = 1223">
                   <li>
                   <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="newsTitle"/></a>
                   </li>
       </xsl:if>

    Sorry if this is not what you are looking for.

     


     

Please Sign in or register to post replies

Write your reply to:

Draft