On my test page, , I am using the following xlst (below) to out put the footer menu and to insert unique classes so they can be styled to match the design specified. Unfortunately, one of the nodes was named Products/Services and the slash kills the css. I changed the name of the node to ProductsService to make my css work but is there a way to write just the first word in the Node name as class instead of the whole thing?
Although Rich's suggestion will work, I still think it's a bad design to "synchronize" the css class name with the name of the node (or part of the node name), you'll always run into issues as you've just experienced, but also when new nodes are created that need to have chars replaced (umbracoSettings.config has the list of replaced chars), but also when renaming nodes. As you'll base the css class name on the node name, you'll have to do an intervention anytime this changes.
I'd look into adding the css class name as a property on the node and hide that property using this project.
I don't really follow the second suggestion and there is no time left in the project so I'm attempting to strip out the special character as per Rich's suggest.
changed special character in node name
On my test page, , I am using the following xlst (below) to out put the footer menu and to insert unique classes so they can be styled to match the design specified. Unfortunately, one of the nodes was named Products/Services and the slash kills the css. I changed the name of the node to ProductsService to make my css work but is there a way to write just the first word in the Node name as class instead of the whole thing?
Thanks in advance!
Hi,
You could just strip out your special character
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:attribute name="class"><xsl:value-of select="umbraco.library:Replace(@nodeName, '/', '')"/></xsl:attribute></a></h3> >
Best of luck
Rich
Teena,
Although Rich's suggestion will work, I still think it's a bad design to "synchronize" the css class name with the name of the node (or part of the node name), you'll always run into issues as you've just experienced, but also when new nodes are created that need to have chars replaced (umbracoSettings.config has the list of replaced chars), but also when renaming nodes. As you'll base the css class name on the node name, you'll have to do an intervention anytime this changes.
I'd look into adding the css class name as a property on the node and hide that property using this project.
Hope this helps.
Regards,
/Dirk
Agree that Dirks solution is much better in the long run.
Rich
I don't really follow the second suggestion and there is no time left in the project so I'm attempting to strip out the special character as per Rich's suggest.
Inserting:
<a href="{umbraco.library:NiceUrl(@id)}"><xsl:attribute name="class"><xsl:value-of select="umbraco.library:Replace(@nodeName, '/', '')"/></xsl:attribute></a></h3> >
Resulted in h3 tags containing ">" across the board. Tried removing the final ">", this resulted in empty h3 tags.
Edited to include <xsl:value-of select="@nodeName"/> where I expect to display the visible link:
This returns a visible link of "ProductServices" :
Kinda back where I started the long way around. I guess I need to add the slash back in for link display?
Any suggestions appreciated.
Teena,
Your last entry doesn't make sense
This must mean your node is called "Products and Services". Also there's no mention style="display" etc in your XSLT.
This code should work (exactly the same as your code posted above)
Maybe post the whole XSLT you are trying.
Dirks suggestion makes perfect sense, so not sure what's hard to follow.
Basically it's saying, add a attribute to your DocType named "cssclass" then in your XSLT
Then in your Product & Services node just fill in the exact name you want for your css class.
Rich
Here's the xlst:
Here's the code it generates at in the footer at Products/Services:
My content page properties:
Hi Teena,
This should work for you
Although this should work it will become a problem if your user changes the name of the node.
Rich
Thanks Rich,
This worked wonderfully, just what I was looking for.
Thanks for your help!
is working on a reply...