Copied to clipboard

Flag this post as spam?

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


  • MikeD 92 posts 112 karma points
    Jul 21, 2011 @ 16:03
    MikeD
    0

    Getting header image for parent node

    I hope this will make sense...

    I have a website with say 5 nodes in the first tier of navigation... aka my main menu items.  Each node will have it's own header image... some of the nodes have 20 or 30 child nodes... I'd rather not have to insert the header for each and every page, and I'd rather not have 5 or 6 versions of each template.

    What I would like to be able to do is insert a macro or something in my template to find the header assigned to the parent node, and display that header.  Is this possible?

    Thanks guys!

  • Profiterole 232 posts 264 karma points
    Jul 21, 2011 @ 16:08
    Profiterole
    0

    Hi, for the 5 parents nodes, create a property with the image in it and, in the template, call the image recursively, so the child will look for the parent.

  • MikeD 92 posts 112 karma points
    Jul 21, 2011 @ 16:20
    MikeD
    0

    ok, you gotta put that in idiot speak... ROFL.  I am not a guru, I'm a cut and paste kinda guy.

    Assuming each parent node is doc type TextPage and template TextPage... both of which are used in child nodes as well...

    I'm gonna have to make new doc types I bet... 

    Did I mention this site is already live?  LOL

  • Profiterole 232 posts 264 karma points
    Jul 21, 2011 @ 17:42
    Profiterole
    0

    Ok, so it's live... ok, you'll put a macro in your header that will choose the right img.

    the macro :

    if test="contain(umbraco.library:NiceUrl($currentPage/@id),'parent folder')"

    img

    /if

    And you do that for all you headers. The test says : "if the url contains 'parent folder', then img".

    Hope it will help!

  • MikeD 92 posts 112 karma points
    Jul 21, 2011 @ 17:57
    MikeD
    0

    System.Xml.Xsl.XslLoadException: 'contain()' is an unknown XSLT function.

     

        <xsl:if test="contain(umbraco.library:NiceUrl($currentPage/@id),'parent folder')">
          <img src='<xsl:value-of select="PageHeader"/>' />
        </xsl:if>

  • Profiterole 232 posts 264 karma points
    Jul 22, 2011 @ 01:58
    Profiterole
    0

    I'm still alive!! Ok, contains with an S... my bad! You have to replace the parent folder.

    Exemple : My parent node is "Students" and, under I have child nodes "Homework" and "Exam". When I'll go to exam.aspx, the url will look like : www.mysite.com/students/exam.aspx

    So, the test will check if the word 'students' (whitout the ' ')  is in the url, and, if yes, it will display your img. If not, it will pass is path.

      <xsl:if test="contains(umbraco.library:NiceUrl($currentPage/@id),'parent1')">
        <img src="/image/header1.jpg" />
      </xsl:if>
    <xsl:if test="contains(umbraco.library:NiceUrl($currentPage/@id),'parent2')">
        <img src="/image/header2.jpg" />
      </xsl:if>
    ...
    <img src="/image/default_header.jpg"/>

    Is it clearer?

Please Sign in or register to post replies

Write your reply to:

Draft