Having a problem placing analytics code on my success.phtml page with magento. For some reason, whenever I echo any string with a "&" in it, Magento encodes it and prints out "&", even when it is part of an IMG's src url. For example, this code :
<?php
echo '<img src="zmam=775xxxxx&zmas=1&zmaq=N&quantity=' . $item->getQtyOrdered() . '&pcode=' . $catalog_number . '&zman=' . $lastOrderId . '&zmat=' . $_subtotal . '" width=0 height=0 border=0>';
?>
Prints out this on the receipt page:
<img src="zmam=775xxxxx&zmas=1&zmaq=N&quantity=1.0000&pcode=&zman=Z77436&zmat=8.9500" width="0" height="0" border="0">
This is true for every echo on the page. I can not track anything with a number of different Analytics providers currently. I have googled for awhile now and can not find anything on the subject- so any input at all would be appreciated.
Thank you.
You have to encode your & in HTML, for links and for image-urls. So if you ask me, there is no problem. I don't know, where this comes from - magento doesn't do this, but it is correct.
<img src="http://example.com/file.php?param=123&param2=123">
is the correct way to insert links.
Are you sure, that the url is correct? it looks like, there is a file missing.
And there is an echo before? not a htmlEscape? I know this are stupid questions, but I have no idead where this should come from.
You may know this error of HTML validators?
You may have forgotten to "escape" an ampersand (&) character, thus causing the validator to believe that you created a new, undefined entity that starts with "&". If you wish to cause an "&" to appear within text or a URL, escape it by using "
&
".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.