Copied to clipboard

Flag this post as spam?

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


  • shine 43 posts 83 karma points
    May 28, 2013 @ 08:23
    shine
    0

    how to check Page name in xslt

    hello friends

     

    I want one page whose name is contactus that i want to check the using condition with this page like

    if current page name='contact us'

    condition

    so which kind of code that we can write that direct page name.....

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 28, 2013 @ 08:29
    Dennis Aaen
    0

    Hi Shine,

    Try this, If I remember right this will do it for you.

    <xsl:if test="$currentPage/local-name() = 'contact us'">.......</xsl:if>

    /Dennis

  • shine 43 posts 83 karma points
    May 28, 2013 @ 08:36
    shine
    0

    error

    Error occured

    System.Xml.Xsl.XslLoadException: Expected end of the expression, found '('.
    $currentPage/local-name -->(<-- ) = 'contactus' An error occurred at \635053395468991437_temp.xslt(45,6).
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 28, 2013 @ 09:45
    Dennis Aaen
    1

    Try this instead and see if it works.

    <xsl:iftest="$currentPage/@nodeName = 'contact us'">.......</xsl:if>

    /Dennis

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 28, 2013 @ 21:56
    Chriztian Steinmeier
    1

    Hi shine

    Dennis' 2nd answer is correct - here's a clarification:

    In the Umbraco.config XML file, your 'contact us' page will look something like this:

    <Textpage id="1234" nodeName="contact us" urlName="contact-us" isDoc="">

    (I've left out a lot of attributes for simplicity)

    Here's what a couple of selections will return:

    <xsl:value-of select="local-name($currentPage)" /> <!-- Textpage -->
    
    <xsl:value-of select="name($currentPage)" /> <!-- Textpage -->
    
    <xsl:value-of select="$currentPage/@nodeName" /> <!-- contact us -->
    
    <xsl:value-of select="$currentPage/@urlName" /> <!-- contact-us -->
    
    (The difference between local-name() and name() is that if you ran them on a namespaced element - e.g. <xsl:template>, local-name() would return "template" whereas name() would return "xsl:template")

    /Chriztian

     

Please Sign in or register to post replies

Write your reply to:

Draft