Ok, so I'm assuming what you want, is what you have now, but dynamic right?
If that's the case, then what you'll want to do is use the umbraco.library:GetPreValues method to retreive the list of options then loop through them, something like:
I got a working version similar to bfi's solution, but I like the looks of using GetPreValues as it seems more efficent.
So I copied your code and added the products parent page id of 1110, which I've added to GetPreValues(...). I had to make a change to the second for-each as I was getting an exception.
I'd probably start by removing the filters on the second for-each and re-adding them back one at a time to see where the issue is. If you start with something like:
Any other filters produce the empty ul. After reading my first post, it reads as if the productType could be on the landing page, when in fact it's property of each item page.
Don't really understand what you meant in your last post, but if you are getting the right level from your previus code, does this give you a list of items for group 1?
Which is almost there, but uses the same UL for all the links (product type value of 13). I also need to exlcude the first li with choose group, guess this is simply done testing the position?
Really can't see what would cause the constant nesting for every level, as all the tags seem to be nested correctly. The output from the above should be allong the lines of
Yes, that is the stucture that I'm after. As a test I've moved the second for-each so that it wraps around the nested <ul>, which has fixed the nesting issue, producing:
Very please, thanks. Just one last bit of the puzzle, I need to add a current class, to the nested ul - see note in xslt, although I could fix this with JavaScript.
Building a menu by RadioBox Value
Hi All
Not sure on the best way to describe this, but here goes !!!
I have a stucture of
Home
- products
- item 1 - level 3
- item 2
- item 3
- item 4
...
The product group is set by a value from a RadioBox datatype, the values are 13, 14 and 15. I need use the item nodes and create a menu which mimics;
Group 1
- item 2 - value of 13
- item 3 - value of 13
Group 2
- item 1- value of 14
Group 3
- item 4 - value of 15
I've roughly put together the following xslt, although manily to show the mark-up I have to work with.
Would really apericate some advice on how to tackle this?
Thanks
Eddie
Hi Eddie,
I would make 3 variables for each group:
then for example for group 1:
I hope this helps.
Ok, so I'm assuming what you want, is what you have now, but dynamic right?
If that's the case, then what you'll want to do is use the umbraco.library:GetPreValues method to retreive the list of options then loop through them, something like:
I've not tested it, as I just typed it straight in, but should be pretty much right.
Let me know if you have any problems.
Matt
Hi Matt
I got a working version similar to bfi's solution, but I like the looks of using GetPreValues as it seems more efficent.
So I copied your code and added the products parent page id of 1110, which I've added to GetPreValues(...). I had to make a change to the second for-each as I was getting an exception.
Could you have a look, as I'm getting an empty <ul> tag?
Thanks
Eddie
Hey Eddie,
Looks like you'll need to make a slight change to the last filter, it should be
string(data[alias='productType']) = ./@id
Hope this helps.
Matt
Hi Matt
Still no joy,
Not sure if this makes a difference, but the menu is only used on the item pages?
Thanks
Eddie
Hey Eddie,
I'd probably start by removing the filters on the second for-each and re-adding them back one at a time to see where the issue is. If you start with something like:
$currentPage/ancestor-or-self::node [@level=$level]/node
And see if you get a list of nodes at the right level to start with, then you can re-apply filters untill you find the problem.
Matt
Hi Matt
The correct menu is created with:
Any other filters produce the empty ul. After reading my first post, it reads as if the productType could be on the landing page, when in fact it's property of each item page.
Thanks
Eddie
Hey Eddie,
Don't really understand what you meant in your last post, but if you are getting the right level from your previus code, does this give you a list of items for group 1?
Matt
Hi Matt
Some progress, I'm getting all of the options of the productType, displayed as a menu?
XSLT:
Generated mark-up:
Thanks
Eddie
Hi Matt
Just added updated the xslt to:
Which as created the following:
Which is almost there, but uses the same UL for all the links (product type value of 13). I also need to exlcude the first li with choose group, guess this is simply done testing the position?
Thanks
Eddie
Hey Eddie,
Can you update
string(data[alias='productType'])
to
string(data[@alias='productType'])
(Notice the the @ symbol) and let me know if thats any better?
Matt
RE "Choose group", yea, I'd do an xsl:if round the whole thing, and check that ./@id isn't blank and is greater than 0
Matt
Hi Matt
Cool, had a go and to date the xslt is:
Also added a not in the opening a tag, to see if its possible to add a class (current), when the nested ul contains a current page.
Thanks
Eddie
Hey Eddie,
Not 100% sure, but you could try something like this
That might work.
Matt
Hi Matt
Have tried it works if I set the second for-each to:
The class is appended, to the last ul, but all of the ul are nested within each other, so
Current xslt looks like:
Not sure, how to amend the filters in the second for-each so that the <ul> are not nested?
Thanks for all your time, seems so close.
Eddie
Hey Eddie,
Really can't see what would cause the constant nesting for every level, as all the tags seem to be nested correctly. The output from the above should be allong the lines of
Is this the structure you are after?
Matt
Hi Matt
Yes, that is the stucture that I'm after. As a test I've moved the second for-each so that it wraps around the nested <ul>, which has fixed the nesting issue, producing:
If I change:
to:
Each grouping has the correct stucture, although each group has the same link.
Thanks
Eddie
Ok, I think we might need to put the prevalues id into a variable before the second for each. Lets try
Matt
Hi Matt
Putting the id into a variable, done the trick : -)
Thanks again
Eddie
Awesome!
Glad we finally got there =)
Matt
Hi Matt
Very please, thanks. Just one last bit of the puzzle, I need to add a current class, to the nested ul - see note in xslt, although I could fix this with JavaScript.
Guess I should open this as a new topic?
Thanks
Eddie
Is that not the same thing that you already do with adding the class "select" to the anchor tag? In that case, change your ul to something like this:
Hey Eddie / Sebastiaan,
I think you should just be able to reuse the if statement used to add a class to the group heading.
@sebastiaan - that wouldn't unfortunatley work, as you are not in the second for-each at that point.
Matt
You're right, I missed the for-each loop!
Hi Matt & Sebastiaan,
I tried reusing the if statement earlier on and got an error, seems to work now!!! Must of been the early start...
Thanks again to you both,
Eddie
is working on a reply...