I'm using an accordion menu that can handle a simple "?expandable=[number]" parameter. I want to pass that value in my menu through a doctype property. The number value changes and i want to control i manually.
I had it working by setting it on the href xsl attribute, but that only worked when i was on that specific page and reloaded it ($currentPage/expandableUrl). Then the url was correct. So somehow i need to pass it into my for-each loop (i guess) so my "parameter" gets indexed immediately and always present on my <li>'s when filled in.
I have 4 "main" pages, on each i sell a different product.On each page i have the same accordion menu, but i need a different menu-item expanded on each of these pages.
So it would look something like this if it worked like i want it to;
Product page 1 (href="pagename.aspx?expandable=0") - Subpage to Productpage 1 - same expandable parameter
Product page 2 (href="pagename.aspx?expandable=4")
- Subpage to Productpage 2 - same expandable parameter
Product page 3 (href="pagename.aspx?expandable=5")
- Subpage to Productpage 3 - same expandable parameter
and so forth..
My frontpage href should look like: www.mysite.dk/pagename.aspx?expandable=0
My first post regarding the <li> thing might be a bit misleading. Of course i want the parameter set for the <a> tag, so the parameter gets called when i click a menu link
Actually i don't want to go up or down the three for that value. And i can see now that's my main problem.
The Xslt below works, but sets all hrefs according to the currentPage parameter value. So i guess i just need an if statement if the parameter field is empty, then it should not output the paramete value-of.
<!-- Input the documenttype you want here --> <xsl:variable name="level" select="1"/> <xsl:variable name="expanded" select="$currentPage/expandedUrl"/>
<xsl:template match="/">
<!-- The fun starts here --> <ul id="topnavigation"> <xsl:for-each select="$currentPage/ancestor-or-self::* [@level = $level]/* [string(umbracoNaviHide) != '1' and @isDoc]"> <li> <a> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(@id)" /><xsl:value-of select="$expanded" /> </xsl:attribute> <xsl:if test="$currentPage/@nodeName = current()/@nodeName"> <xsl:attribute name="class">selected</xsl:attribute> </xsl:if> <xsl:value-of select="@nodeName"/>
hmm this proved a bit more of a task than i seem able to handle :/
If i set the property of my frontpage to have ?expandable=0 to open the first accordion menu item, then the rest of my menu items will have the same url.
How do i get the other node parameter values to override that of currentPage?
<!-- Input the documenttype you want here --> <xsl:variable name="level" select="1"/> <xsl:variable name="expanded" select="$currentPage/expandedUrl"/>
<xsl:template match="/">
<!-- The fun starts here --> <!--<textarea> <xsl:copy-of select="$expanded" /> </textarea>-->
Pass doctype value to url in Xslt
Hi
I'm using an accordion menu that can handle a simple "?expandable=[number]" parameter. I want to pass that value in my menu through a doctype property. The number value changes and i want to control i manually.
I had it working by setting it on the href xsl attribute, but that only worked when i was on that specific page and reloaded it ($currentPage/expandableUrl). Then the url was correct. So somehow i need to pass it into my for-each loop (i guess) so my "parameter" gets indexed immediately and always present on my <li>'s when filled in.
How do i go about it?
Clean Xslt:
Could you write an examle of the html you want? And maybe for 2 different pages so i can see the difference of the html ( if there is any )
Hi Anders
Sure, or i can try to examplify it more in depth:
I have 4 "main" pages, on each i sell a different product.On each page i have the same accordion menu, but i need a different menu-item expanded on each of these pages.
So it would look something like this if it worked like i want it to;
Product page 1 (href="pagename.aspx?expandable=0")
- Subpage to Productpage 1 - same expandable parameter
Product page 2 (href="pagename.aspx?expandable=4")
- Subpage to Productpage 2 - same expandable parameter
Product page 3 (href="pagename.aspx?expandable=5")
- Subpage to Productpage 3 - same expandable parameter
and so forth..
My frontpage href should look like: www.mysite.dk/pagename.aspx?expandable=0
Hope that clarifies my original post
My first post regarding the <li> thing might be a bit misleading. Of course i want the parameter set for the <a> tag, so the parameter gets called when i click a menu link
Could you traverse up the xml tree until you find a node with the expandableUrl property and use it at the a tag?
Like
menuItem/ancestor-or-self::* [./expandableUrl][1]/expandableUrl
Hi anders
Actually i don't want to go up or down the three for that value. And i can see now that's my main problem.
The Xslt below works, but sets all hrefs according to the currentPage parameter value. So i guess i just need an if statement if the parameter field is empty, then it should not output the paramete value-of.
I'll try to fix it after lunch
hmm this proved a bit more of a task than i seem able to handle :/
If i set the property of my frontpage to have ?expandable=0 to open the first accordion menu item, then the rest of my menu items will have the same url.
How do i get the other node parameter values to override that of currentPage?
<xsl:if... isn't really working out for me
current xslt:
Alright.
Got i solved with a bit of extra forum reading :-)
For future usage (if any would ever do this).
1. Make a property (mine is called "expandedUrl" without the "")
2. Use following XSLT:
is working on a reply...