render & entity as & on front end woes
This is an open discussion with 8 replies, filed under XSLT.
Search
You cannot output the &
character verbatim in XHTML, it is invalid. If your link URL includes &
then this will be correctly interpreted e.g.
http://yoursite?utm_source=something&utm_medium=somethingelse
That is perfectly fine.
Ok cool.. Got that bit working fine with &
now but I guess I'm trying to also place the same code on clickTag tracking elements on a flash object attribute and it doesn't like the &
and ignores everything after and including the first &
so I guess it's just gonna blow up :)
Using &
has worked for me, but i don't know whether it will work in your context.
Tried that.. here's what I have but everything after the &
is ignored in the URL clicked:
<object type="application/x-shockwave-flash" data="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}?clickTag={banners/entry/link-url}&utm_source={$current-url}&utm_medium={banners/entry/type-of-banner/item}&utm_campaign={banners/entry/campaign-description}&utm_term={banners/entry/advert-description}&utm_content={banners/entry/advert-reference-id}" width="350" height="300"> <param name="movie" value="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}?clickTag={banners/entry/link-url}&utm_source={$current-url}&utm_medium={banners/entry/type-of-banner/item}&utm_campaign={banners/entry/campaign-description}&utm_term={banners/entry/advert-description}&utm_content={banners/entry/advert-reference-id}" /> <a href="{banners/entry/link-url}?utm_source={$current-url}&utm_medium={banners/entry/type-of-banner/item}&utm_campaign={banners/entry/campaign-description}&utm_term={banners/entry/advert-description}&&utm_content={banners/entry/advert-reference-id}" target="_blank"><img src="{$workspace}{banners/entry/alternative-image-banner/@path}/{banners/entry/alternative-image-banner/filename}" /></a> </object>
It works on the a link attibute and the clickTag itself triggers but because there are semi colons in the object attribute it don't like it.
I've been mulling this over for hours, and the only idea I have is to try and use the <xsl:attribute>
tag to add the data
attribute.
This does raise a question though... How come you need click tracking inside an attribute who's sole purpose is to designate the origin of the object
's content?
Is the click tracking for when someone clicks on the object
? If so, then just wrap the object
in an anchor
with the tracking on it. Click tracking on the object
, param
and a nested anchor
is a little excessive IMO... I guess you've done it for fallback, but avoid that by doing the click tracking first.
So wrapping it in an anchor and set the href to include the tracking data?
i.e
<a href="{banners/entry/link-url}?utm_source={$current-url}&utm_medium={banners/entry/type-of-banner/item}&utm_campaign={banners/entry/campaign-description}&utm_term={banners/entry/advert-description}&&utm_content={banners/entry/advert-reference-id}" target="_blank"> <object type="application/x-shockwave-flash" data="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}" width="350" height="300"> <param name="movie" value="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}" /> <img src="{$workspace}{banners/entry/alternative-image-banner/@path}/{banners/entry/alternative-image-banner/filename}" /> </object> </a>
Just trying to simplify the way we can notify the outgoing links analytics of the origin of the banner advert.. possibly all wrong but I take your point about excessive.. yes it's for fallback purposes. but wrapping object in anchor is that valid?
Yeah, wrapping an object
in an anchor
is perfectly valid XHTML.
I hope it all works!
Sweet thanks desingermonkey. All purring away nicely now.
Create an account or sign in to comment.
Ummm I'm trying to output an ampersand symbol
&
to render as&
onthe front end in my xsl page template but it's just not playing ball.. saying:And my code is as follows:
If I change the
&
to$amp;
it validates and renders fine on the front end.. but I want it to output as&
for tracking purposes.. any thoughts?