Copied to clipboard

Flag this post as spam?

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


  • Mark Bro 15 posts 86 karma points
    May 16, 2013 @ 22:37
    Mark Bro
    0

    XSLT Top nav

    Hi All,

    With regards to the top Nav's HOME link, I would like to be able to get a parent page property and use that in the <a href="/">Home</a> section rather than hardcoding to the root of the site, like

     <a href="parentssiterootproperty ">Home</a>

    Any help would be appreciated, thanks.

     

     <ul id="topNavigation">
           <li class="home">
             <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                 <xsl:attribute name="class">home current</xsl:attribute>
             </xsl:if>
         <xsl:variable name="URL">
          <xsl:value-of select="pageTitle"/>
         </xsl:variable>
         <a href="/">Home</a>

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 17, 2013 @ 01:37
    Chriztian Steinmeier
    0

    Hi Mark,

    You can grab it like this:

    <a href="{$currentPage/../parentPageProperty}">Home</a>
    

    - or, if parentPageProperty is a NodePicker (i.e. it only contains an ID):

    <a href="{umbraco.library:NiceUrl($currentPage/../parentPageProperty)}">Home</a>

    Please note though, that this usually gives you a URL like this: /sitename - which (if it's the same location as the root, i.e., if you only have a single site in your install) can give you duplicate content issues with the GoogleBot. 

    /Chriztian

  • Mark Bro 15 posts 86 karma points
    May 17, 2013 @ 01:55
    Mark Bro
    0

    Hi Chriztian,

    Thanks for the prompt reply. The node structure I have is like the following

    Content - Node 1 - Page1
    --------------------------- Page 2
    ----------------------------Page3 etc

    Content - Node 2 - Page 1
    -------------------------- -Page 2
    ----------------------------Page 3 etc

     

    Node 1 & two have a property called siteRoot. What I would like to happen on the Top nav is when HOME is clicked default node above the preivous page using the siteRoot value on the node. Tried below but when using the visualize xslt the hyperlink is  ...../umbraco/developer/xslt  and doesn't have the siteRoot value?

    Any thoughts??

    <ul id="topNavigation">
           <li class="home">
             <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                 <xsl:attribute name="class">home current</xsl:attribute>
             </xsl:if>
        
         <a href="{$currentPage/../siteRoot}">Home</a>
      

     

       

     

     

     

      

     

     

     

  • Mark Bro 15 posts 86 karma points
    May 19, 2013 @ 23:54
    Mark Bro
    0

    I've managed to get the parentsproperty value back using

    <ahref="{$currentPage/../parentPageProperty}">Home</a>

    However the url is

    http:/siteroot/currentpage/parentproperty

    how do I get the url to be just

    http://siteroot/parentproperty

    Most things I've tried says out of scope

     

     

     

     

     

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    May 20, 2013 @ 19:57
    Chriztian Steinmeier
    100

    Hi Mark,

    That's happening because if you link like this: <a href="go-here"> - this is a relative link, so the browser will add it to the URL of whichever page you're currently on.

    So you'll have to write an absolute link, which is easily done by adding the http:// to it, like this:

    <a href="http://siteroot/{$currentPage/../parentPageProperty}">Home</a>

    /Chriztian

  • Mark Bro 15 posts 86 karma points
    May 20, 2013 @ 21:33
    Mark Bro
    0

    Worked like a treat. Thanks for all your help Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft