Copied to clipboard

Flag this post as spam?

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


  • andi8u 10 posts 30 karma points
    Sep 07, 2011 @ 16:33
    andi8u
    0

    Detecting the branch in a multilingual site

    Hello !

    I want to integrate a basic sitemap in my multilingual site, and it has to be different for all the languages.

    My site has this structure:

    I want to detect if i'm on a subnode(doesn't  matter how deep) of de or en so that i can generate the proper sitemap. Also can a macro be called from another macro in xslt.

    Thanks!

  • Euan Rae 105 posts 135 karma points
    Sep 08, 2011 @ 11:57
    Euan Rae
    0

    to get which parent node you're under

    <xsl:if test="$currentPage::ancestor-or-self/*/@id = 1000"/> - double check the syntax, but that's the general idea

    you can't call another macro from an xslt macro per se, but if you add a reference to another xslt file, you can call templates that are in the referenced xslt file

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 12:02
    Dirk De Grave
    0

    you can use 

    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = 1]/* [@isDoc and string(./umbracoNaviHide) != '1']">
    ...
    </xsl:for-each> 

    as a first statement for your sitemap xslt (they will get you to the en or de node) and generate the sitemap starting from that node

     

    Hope this helps.

    Cheers,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 12:04
    Dirk De Grave
    0

    And you CAN call another macro from xslt, but only if that macro also references a xslt file (not a user control). use umbraco.library:RenderMacro(). Anyway, Euan's suggestion of using includes is preferred in this case.

     

    Cheers,

    /Dirk

  • Euan Rae 105 posts 135 karma points
    Sep 08, 2011 @ 12:06
    Euan Rae
    0

    Wow, you learn something every day :) Is using includes faster than using umbraco.library:RenderMacro()?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 08, 2011 @ 12:13
    Dirk De Grave
    0

    i have no stats on performance of using includes vs RenderMacro, so wouldn't know. Anyway, think includes is a nicer solution compared to using RenderMacro. Keep one thing in mind (unless that's been solved, it used to be an issue), is if you're changing a xslt that includes another xslt, you need to save both (also the included xslt) before you'd see any changes...

     

    Cheers,

    /Dirk

  • andi8u 10 posts 30 karma points
    Sep 08, 2011 @ 16:25
    andi8u
    0

    Wow thanks for both the solutions !

    Both worked like a charm :)

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 08, 2011 @ 21:20
    Chriztian Steinmeier
    0

    Hi andi8u - another approach:

    I usually do this in multilingual setups:

    <xsl:param name="currentPage" />
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::Website" />

    - If you don't use a specific Document Type for the root of each site, you can just check the level attribute:

    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    

    Now you can ask:

    <xsl:if test="$siteRoot/@nodeName = 'en'">
        <!-- do stuff in english -->
    </xsl:if>
    

    or you can just do language-specific stuff:

    <xsl:for-each select="$siteRoot[@nodeName = 'de']//NewsItem">
        <!-- Do something in german -->
    </xsl:for-each> 

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft