Copied to clipboard

Flag this post as spam?

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


  • CodeMaster2008 151 posts 184 karma points
    Apr 08, 2010 @ 19:59
    CodeMaster2008
    0

    Equivalent to "recursive" on macros

    Hi there,
    Let's say i have a property on a master template and i wan't to access this property on child templates, i can do that using the recursive parameter, right?

    <umbraco:Item field="SiteLogo" recursive="true" runat="server"></umbraco:Item>

    But how can i get something similar inside a macro? I'm trying to use macro to render a logo, however, this macro can be used on any sub page including different levels, so this won't work:

    <xsl:variable name="logoid" select="data [@alias = 'SiteLogo']"/>

    Is my only option loop through all parent nodes until i get to the master page? Here is my tree:

    TEMPLATES
    - Master Template
     - Home
     - Two Columns
    WEB SITE
    - Content
     - Home Page
       - Page 1

       - Products
         - Product 1
         - Product 2
  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Apr 08, 2010 @ 20:41
    Chriztian Steinmeier
    3

    Hi CodeMaster2008,

    You can do that by taking the value from the first node in the ancestor-or-self:: axis that has that property; like this:

    <xsl:variable name="logoid" select="$currentPage/ancestor-or-self::node[data[@alias = 'SiteLogo']][1]/data[@alias='SiteLogo']" />

    (Depending on the context, you might not need to include the $currentPage parameter)

    /Chriztian

  • CodeMaster2008 151 posts 184 karma points
    Apr 08, 2010 @ 21:58
    CodeMaster2008
    0

    Thanks a lot, exactly what i need.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies