When I try to access the links on the level 2 navigation everything works well but when I try to access the level 3 navigation, example I click the meetings and conferences and then try to go back to level 2 navigation, Im now encountering a problem because the navigation now looks for the link under the meetings and events.
Error in navigation url
Hello,
It's me again.
I have a content that looks like this.
Home
- Meetings and Events
- Meetings and conferences
- Social Events
- Hotel 1
- Hotel 2
When I try to access the links on the level 2 navigation everything works well but when I try to access the level 3 navigation, example I click the meetings and conferences and then try to go back to level 2 navigation, Im now encountering a problem because the navigation now looks for the link under the meetings and events.
My url now looks like http://localhost/home/meetings-and-events/home.aspx instead of http://localhost/home/home.aspx
How do I make my navigation retain its url regardles of the page I click?
Can you show us your xslt you've got so far for building up the navigation?
Cheers,
/Dirk
Here's my xslt file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<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"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<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 id="nav">
<li id='navMain2'><a href='en.aspx' title='Home' class="selected">Home</a></li>
<li id='navMain3'><a href='#' title='Hotels'>Hotels</a>
<ul>
<li><a href='dubai-flora-grand-hotel.aspx' title='Flora Grand'>Flora Grand Hotel</a></li>
<li><a href='dubai-hotel-florida-international.aspx' title='Florida International'>Hotel Florida International</a></li>
<li><a href='dubai-florida-hotel.aspx' title='Florida Hotel'>Florida Hotel Dubai</a></li>
</ul>
</li>
<li id='navMain4'><a href='#' title='Hotel Apartments'>Hotel Apartments</a>
<ul>
<li><a href='dubai-flora-hotel-apartments.aspx' title='Flora Hotel'>Flora Hotel Apartments</a></li>
<li><a href='dubai-flora-creek-hotel-apartments.aspx' title='Flora Creek'>Flora Creek Hotel Apartments</a></li>
<li><a href='dubai-flora-park-hotel-aparments.aspx' title='Flora Park'>Flora Park Hotel Apartments</a></li>
</ul>
</li>
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li class="navMain5">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
And then this is my right navigation xslt.
Supposedly for each item selected on my top navigation a corresponding links will be shown on the right side bar.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<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"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="2"/>
<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:if test="$currentPage/@id = current()/@id">
<xsl:attribute name="class"><xsl:text>selected</xsl:text></xsl:attribute>
</xsl:if>
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
I'm pretty sure it's because of the relative links on your navigation, try changing so "/" is included in your href attribute.
For example, don't use:
but instead, use
(NiceUrl() will do this by default for you, but if you're including other links, add a "/")
Also, it's generally a bad idea to not use the NiceUrl(), because your document name may change and your link will become broken.ยต
For example:
will be broken is someone changes the name from 'Dubai Flora Grand Hotel' to 'Dubai Flora Big and Grand Hotel'
Hope this helps.
Regards,
/Dirk
I will change the hotel link and not use hard coded href values.
But for the home page because my client wants to include a home link, I try your suggestion to put a "/" on my href values but now
what it does is go to this url http://localhost/en.aspx instead of http://localhost/florahospitality/en.aspx.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.