Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    Jun 02, 2011 @ 12:20
    hetaurhet
    0

    URL picker and top navigation menu

    hello

    i am using umbraco 4.7.0. I have created top navigation menu using umbraco xslt template 'list subpages by level'.

    This works fine for internal url. For one of the menu item i want to give external url, so for that I am using uComponent's URL picker. I installed this package. Added one property with 'URL picker' type in document type. Made content page from this doc type and specified external link in 'url' field of URL picker.

    But for this external link, menu navigation is not working. i.e. it search for page in /root folder of the web site like other internal content pages. what changes I need to do now in xslt file of top navigation menu?

    please its urgent......

     

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 02, 2011 @ 12:55
    Lee Kelleher
    0

    Hi hetaurhet,

    Could you post your XSLT snippet? Have you made any changes to the "list subpages by level" template?

    Should only require a tweak to the <a href> to use the Url Picker instead of the NiceUrl call.

    Cheers, Lee.

  • hetaurhet 245 posts 267 karma points
    Jun 02, 2011 @ 13:46
    hetaurhet
    0
    <?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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml
    umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
    Exslt.ExsltSets tagsLib BlogLibrary "
    >

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

    <xsl:param name="currentPage"/>

    <!-- Input the documenttype you want here -->
    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    using 4.7.0 version.. so will need code related to this.

    
    
                
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 02, 2011 @ 14:09
    Lee Kelleher
    0

    Hi hetaurhet,

    See my example snippet.  I have added a check to see if the "url" field has a value - if so, then it will use that (instead of the NiceUrl call).

    <a href="{umbraco.library:NiceUrl(@id)}">
        <xsl:if test="normalize-space(url)">
            <xsl:attribute name="href">
                <xsl:value-of select="url"/>
            </xsl:attribute>
        </xsl:if>
        <xsl:value-of select="@nodeName"/>
    </a>

    Hope that makes sense?

    Cheers, Lee.

  • hetaurhet 245 posts 267 karma points
    Jun 02, 2011 @ 15:47
    hetaurhet
    0

    no, its not working. but still can you explain me following lines from your code?

    normalize-space(url) and 

    <xsl:attribute name="href">
                           
    <xsl:value-of select="url"/>
                   
    </xsl:attribute>

    property name which i am using is urlpicker on my doc type ....

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 02, 2011 @ 16:17
    Lee Kelleher
    0

    Hi hetaurhet,

    Sure, there are a few ways to do this... guess I opted for the more advanced version (sorry).

    "normalize-space" is an XPath function that will remove all whitespaces from a value ... along with this, if it is used as a condition (in an if/when test statement), then it will return true if the string is not empty and false if it is empty.  It's pretty much the same as saying "urlpicker != ''", but takes whitespace into consideration.

    The <xsl:attribute> tag, does just that... adds an attribute to the parent HTML/XML element.  So in my example, it would replace the existing "href" attribute that was set.

     

    Here's a revised code snippet for you...

    <a>
        <xsl:attribute name="href">
            <xsl:choose>
                <xsl:when test="urlpicker != ''">
                    <xsl:value-of select="urlpicker"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:value-of select="@nodeName"/>
    </a>

     

    Cheers, Lee.

  • hetaurhet 245 posts 267 karma points
    Jun 03, 2011 @ 10:47
    hetaurhet
    0

    its not going into following if statement for external link

    <xsl:when test="urlpicker != ''">
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 03, 2011 @ 11:21
    Lee Kelleher
    0

    Hi hetaurhet,

    Sorry, I'd completely forgot that Url Picker uses different underlying data-sources.  Which one are you using, XML or CSV?

    Hopefully you are using XML.  If so, then modify your XSLT like so...

    <a>
        <xsl:attribute name="href">
            <xsl:choose>
                <xsl:when test="urlpicker/url-picker/url != ''">
                    <xsl:value-of select="urlpicker/url-picker/url"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="umbraco.library:NiceUrl(@id)"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
        <xsl:value-of select="@nodeName"/>
    </a>

    There is documentation about the UrlPicker data-type on CodePlex - if you are curious about the finer details.

    Cheers, Lee.

  • hetaurhet 245 posts 267 karma points
    Jun 03, 2011 @ 11:43
    hetaurhet
    0

    i am using xml. and make changes u say in xslt file. the above code is also not working.....

    when we use url picker... can you tell the steps of how to create external link under home page node? i am just creating content page from the doc type which has one of its property of the type 'url picker'.

  • hetaurhet 245 posts 267 karma points
    Jun 03, 2011 @ 11:54
    hetaurhet
    0

    i am using xml. and make changes u say in xslt file. the above code is also not working.....

    when we use url picker... can you tell the steps of how to create external link under home page node? i am just creating content page from the doc type which has one of its property of the type 'url picker'.

Please Sign in or register to post replies

Write your reply to:

Draft