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
    May 29, 2011 @ 08:08
    hetaurhet
    0

    extranal link on menu item using xslt and macro

    One of the links of top menu is extarnal link. So for this to accomplish I searched through Forums and got solution but i am stucked.

    I created document type called ExternalLink with two properties link and linkDescription. Then created a page from this document type.

    Also, created xslt file called DBTopNav.xslt with following code and inserted its macro in my home page template.

    <?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::node  [@level=$level]/node [string(data [@alias='umbracoNaviHide']) !=  '1']">
        <li>
            <xsl:choose>
                <xsl:when test="string(./@nodeTypeAlias) = 'ExternalLink'">
                    <a href="{./data [@alias='link']}">
                        <xsl:value-of select="./data [@alias='linkDescription']"/>
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName"/>
                    </a>
                </xsl:otherwise>
            </xsl:choose>    
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

    But when I run the home page, I can't see menu itself.

  • hetaurhet 245 posts 267 karma points
    May 31, 2011 @ 06:58
    hetaurhet
    0

    anyone there who can help?

  • Jesper Hauge 298 posts 487 karma points c-trib
    May 31, 2011 @ 08:48
    Jesper Hauge
    0

    Hi hetaurhet,

    Your xslt is based on the old xml schema, which means it would output only an empty <ul />, if it's running on a umbraco version newer or equal to v4.5 it will probably be using the new xml-schema.

    Can you verify your version number (click the "About" button in Umbraco UI), and if newer than v4.5 check the value in <UseLegacyXmlSchema> in /config/umbracoSettings.config?

    Regards
    Jesper Hauge

  • hetaurhet 245 posts 267 karma points
    May 31, 2011 @ 17:34
    hetaurhet
    0

    yes, my umbraco version is 4.7.0. UseLegacyXmlSchema is as follows in config/umbracoSettings.config file.

    <UseLegacyXmlSchema>false</UseLegacyXmlSchema>

    so what I have to change now?

  • Jesper Hauge 298 posts 487 karma points c-trib
    Jun 01, 2011 @ 08:39
    Jesper Hauge
    0

    Hi hetaurhet,

    Then you have to change the xslt to match the xml it's transforming. Try something like this:

    <?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::root/*[@level=$level and string(./umbracoNaviHide) !=  '1']">
        <li>
            <xsl:choose>
                <xsl:when test="name(.) = 'ExternalLink'">
                    <a href="{./link}">
                        <xsl:value-of select="./linkDescription"/>
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <a href="{umbraco.library:NiceUrl(@id)}">
                        <xsl:value-of select="@nodeName"/>
                    </a>
                </xsl:otherwise>
            </xsl:choose>    
        </li>
    </xsl:for-each>
    </ul>
    
    </xsl:template>
    
    </xsl:stylesheet>

    You can read about the schemas here:
    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema

    Regards
    Jesper Hauge

     

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jun 01, 2011 @ 08:50
    Simon Dingley
    0

    You may also want to take a look at the Url Picker component in uComponents, see documentation here

    http://ucomponents.codeplex.com/wikipage?title=UrlPicker

  • hetaurhet 245 posts 267 karma points
    Jun 02, 2011 @ 08:07
    hetaurhet
    0

    I installed uComponets. Used URL picker data type in my one of the document type. Made a content page from this document type for url picker and set its value to external link e.g. http://www.google.com. But now when i run the page or see preview, its not going to that page. can you help me to solve this?

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Jun 02, 2011 @ 08:32
    Simon Dingley
    0

    I have to leave to see a client now but your best bet for help would be to post on the uComponents forum if you are still stuck.

    See http://our.umbraco.org/projects/backoffice-extensions/ucomponents/questionssuggestions

  • hetaurhet 245 posts 267 karma points
    Jun 03, 2011 @ 06:12
    hetaurhet
    0

    ok... will do that

Please Sign in or register to post replies

Write your reply to:

Draft