简体   繁体   English

Magento Success.phtml HTML编码所有内容

[英]Magento Success.phtml Html Encoding Everything

Having a problem placing analytics code on my success.phtml page with magento. 使用magento在我的success.phtml页面上放置分析代码时遇到问题。 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. 由于某些原因,无论何时我回显任何带有“&”的字符串,Magento都会对其进行编码并打印出“&”,即使它是IMG的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&amp;zmas=1&amp;zmaq=N&amp;quantity=1.0000&amp;pcode=&amp;zman=Z77436&amp;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. 我目前无法使用许多其他Google Analytics(分析)提供商跟踪任何内容。 I have googled for awhile now and can not find anything on the subject- so any input at all would be appreciated. 我已经在Google上搜索了一段时间,但找不到关于该主题的任何内容-因此,我们将不胜感激。

Thank you. 谢谢。

You have to encode your & in HTML, for links and for image-urls. 您必须将HTML中的&编码为链接和图像URL。 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. 我不知道这是哪里来的-magento不会这样做,但这是正确的。

<img src="http://example.com/file.php?param=123&amp;param2=123"> is the correct way to insert links. <img src="http://example.com/file.php?param=123&amp;param2=123">是插入链接的正确方法。

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? 不是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? 您可能知道HTML验证程序的此错误吗?

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 " &amp; ". 如果希望使“&”出现在文本或URL中,请使用“ &amp; ”将其转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM