Copied to clipboard

Flag this post as spam?

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


  • Kate 267 posts 610 karma points
    Sep 11, 2013 @ 12:04
    Kate
    0

    Find Template name one level up

    I'm making a site where there is a submenu.
    This submenu must sometimes be displayed along with a map.

    I have a template called TextPage - this is where I insert the submenu macro.

    If the TextPage is a subpage to a template called "Destination" then the submenu should show submenu and a map, otherwise the TextPage should only contain the sumbenu

    My Structur look like this:

    Site
      - Frontpage
      - TextPage (only show submenu)
           TextPage (only show submenu)
      - Destination
            TextPage (show submenu and map)

    how can I in my xslt file describe whether I am on at TextPage that is a subpage to template "Destination" or just a regular TextPage?


    Thanks in advance

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 11, 2013 @ 12:20
    Chriztian Steinmeier
    100

    Hi Kate,

    If you're using match templates in your XSLT you can differentiate just by adding the Destination - e.g.,:

    <!-- Standard template -->
    <xsl:template match="TextPage">
        <p><xsl:value-of select="@nodeName" /></p>
    </xsl:template>
    
    <!-- Subpages of Destination -->
    <xsl:template match="Destination/TextPage">
        <p>Sub: <xsl:value-of select="@nodeName" /></p>
    </xsl:template>
    

    (Note: These are DocumentType aliases of the pages)

    Is this enough info to get it working?

    /Chriztian

  • Kate 267 posts 610 karma points
    Sep 11, 2013 @ 12:38
    Kate
    0

    Hi Chriztian

    Sorry, I need a bit more help.

    This is what I wrote in my xslt. Just as an example. But I cant get it to work

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <!-- Standard template -->
    <xsl:template match="TekstSide" mode="output">
    <div style="background:red;position:absolute;z-index:5000;height:100px;">ikke under destination</div>
    </xsl:template>

    <!-- Subpages of Destination -->
    <xsl:template match="Destinationer/Destination/TekstSide" mode="output">
    <div style="background:orange;position:absolute;z-index:5000;height:100px;">Sub: </div>
    </xsl:template>




    </xsl:stylesheet>

     

  • Kate 267 posts 610 karma points
    Sep 11, 2013 @ 12:43
    Kate
    0

    This is what my content tree looks like

  • Kate 267 posts 610 karma points
    Sep 11, 2013 @ 13:35
    Kate
    0

    Hi Chriztian

    I found your site http://pimpmyxslt.com/articles/match-templates-intro/ and that was a great help.

    So Thanks for your help. It works now :-)

    /Kate

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 11, 2013 @ 13:59
    Chriztian Steinmeier
    0

    Ha, that is great :)

    I didn't think to link to that article - but of course...

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft