Copied to clipboard

Flag this post as spam?

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


  • Deepali Bhola 23 posts 43 karma points
    Aug 08, 2012 @ 14:42
    Deepali Bhola
    0

    making navigation menu name diff. from page name

    Hi all,

    Can it be Possible to make Menu Title name differant from actual pagename

    Eg: In Top Navigation menu apperes "Home" and actual page name is default.aspx

    plz guide!!

     

  • Dan 1288 posts 3921 karma points c-trib
    Aug 08, 2012 @ 14:45
    Dan
    0

    Hi Deepali,

    Yes that's simple to do.  Just create a new property on your document type called 'Menu title' and in your Razor/XSLT macro use that property rather than the nodeName property.  This will effectively de-couple the node name from the navigation text.

  • Deepali Bhola 23 posts 43 karma points
    Aug 08, 2012 @ 15:17
    Deepali Bhola
    0

    Thanks for help

    i get your logic, 

    but really grateful if u explan me the syntax (how to use property name), this is my Razor script which i have used in master tamplete. and created property with name "Menu Title"

    <umbraco:macro id="Macro1" runat="server" language="cshtml"><ul>
                @{ var homeNode = Model.AncestorOrSelf("Home"); }
                <li><a href="@homeNode.Url" class="@Library.If(homeNode.Id == Model.Id,"selected", "")">
                 <span class="lft"></span><span class="mdl">
                    @homeNode.Name
                </span><span class="rgt"></span>
                </a></li>             
                  @foreach (var page in homeNode.Children.Where("Visible"))
                {
                <li>
                <a href="@page.Url" class="@Library.If(page.Id == Model.Id,
                "selected", "")"><span class="lft"></span><span class="mdl">@page.Name
                </span><span class="rgt">
                </a>
                </li>
                  }
      </ul> 
    </umbraco:macro>

     

    Thanks in advance. :)

  • Deepali Bhola 23 posts 43 karma points
    Aug 08, 2012 @ 15:26
    Deepali Bhola
    0

    Hey i have done it : )

    Thanks alot..

  • Dan 1288 posts 3921 karma points c-trib
    Aug 08, 2012 @ 15:29
    Dan
    0

    Great - glad it worked.  I must admit I haven't done much razor, but I'd suspect it was something like replacing @page.Name with @page.MenuTitle, right?

  • Deepali Bhola 23 posts 43 karma points
    Aug 08, 2012 @ 15:31
    Deepali Bhola
    0

     

    Absolutely this.. with alias

  • Natasha 79 posts 195 karma points
    Aug 05, 2013 @ 17:33
    Natasha
    0

    Hi Dan or anyone else

    How would I do the same thing but with an XSLT?  I have this at the moment, but it's not doing any thing  Thanks for your help in advance

    Natasha

     

    <?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:Examine="urn:Examine" xmlns:umbraco.contour="urn:umbraco.contour" 

    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Examine umbraco.contour ">

     

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

     

    <xsl:param name="currentPage"/>

     

    <!-- Don't change this, but add a 'contentPicker' element to -->

    <!-- your macro with an alias named 'source' -->

    <xsl:variable name="source" select="/macro/source"/>

     

    <xsl:template match="/">

     

    <!-- The fun starts here -->

    <ul class="send_top_nav">

    <li><a href="1198">Home</a></li>

    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">

    <li>

    <xsl:choose>

    <xsl:when test="$currentPage/pageNameMenu != ''">

    <a href="{umbraco.library:NiceUrl(@id)}">

    <xsl:value-of select="$currentPage/pageNameMenu"/>

    </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>

    <li><a href="/home.aspx">ABA Home</a></li>

    </ul>

     

    </xsl:template>

     

    </xsl:stylesheet>

  • Sagar 74 posts 275 karma points
    Jun 08, 2016 @ 05:18
    Sagar
    0

    Instead of doing that much amount of code Insert a field in your Document Type with Name "URL Name" (Text String) with Alias name "UmbracoUrlName" and then in your Content enter any name of your wish which would be your URL name

    Cheers Sagar----

Please Sign in or register to post replies

Write your reply to:

Draft