which is a shame as its longer, harder to read and just a bit of a pain in the ass. But it works. An advantage to this way though is you save 6 bytes being sent down the wire if no id is needed but...
Any alternatives or fixes anyone knows of?
After reading the "tips on using XSL" which showed you can use Entities I thought that might be a nice way around it but equally I don't think its a good idea to go around polluting your entities list all the time as its not a straight forward technique so hinders debugging, still might work nicely this is instance.
umbraco:Items can't be the value for an HTML id field
I want to simply render out a different id on my body tag depending on the page.
<body id="something">
But its not easy, I'm guessing this is due to a .net limitation but I've noticed that you can't do this:
<body id="<umbraco:Item field="Page.BodyTagID" stripParagraph="true" runat="server" />">
as it caused this error:
Parser Error Message: '"<umbraco:Item' is not a valid identifier.
Instead you have do this using before and after text attributes:
<body<umbraco:Item field="Page.BodyTagID" insertTextBefore=" id="" insertTextAfter=""" stripParagraph="true" runat="server" />
which is a shame as its longer, harder to read and just a bit of a pain in the ass. But it works. An advantage to this way though is you save 6 bytes being sent down the wire if no id is needed but...
Any alternatives or fixes anyone knows of?
After reading the "tips on using XSL" which showed you can use Entities I thought that might be a nice way around it but equally I don't think its a good idea to go around polluting your entities list all the time as its not a straight forward technique so hinders debugging, still might work nicely this is instance.
Well you could always do it with single quotes, much easier on the eyes:
<body id='<umbraco:Item field="Page.BodyTagID" stripParagraph="true" runat="server" />'>
But not valid HTML :(
Hi Peter
Try what Sebastian is suggesting and you'll see that the output generated is perfectly valid allthough the code looks rather ugly.
/Jan
Yes, the W3 validator doesn't care whether you use single our double quotes! Just keep the start and end quote style the same and you're good to go.
Ok so it works, but my built in validator in my head does not like it :)
Still with a little juggling of the quote I got it to work using singles for the umbraco tag and doubles around the attribute, win win.
<body id="<umbraco:Item field='Page.BodyTagID' stripParagraph='true' runat='server' />">
Thanks guys.
is working on a reply...