我正在尝试通过我的xml文件将我的链接添加到head部分,但没有任何反应(magento 1.7.0.2)
<action method="addLinkRel"><rel>canonical</rel><href>http://fonts.googleapis.com/css?family=Dancing+Script</href></action>
请说出正确的方法。
答案 0 :(得分:4)
也许是这样的,显示完整的布局XML结构:
<?xml version="1.0"?>
<layout>
<default>
<reference name="head">
<block type="core/text" name="any.name.here">
<action method="setText"><text><![CDATA[<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Dancing+Script">]]></text></action>
</block>
</reference>
</default>
</layout>
setText可以让你做任何事情,对于任何第三方js或css来说都是安全的选择。
答案 1 :(得分:3)
<rel>canonical</rel>
用于向头部添加规范链接。
要添加样式表,请使用:
<reference name="head">
<action method="addLinkRel">
<rel>stylesheet</rel>
<href>http://fonts.googleapis.com/css?family=Dancing+Script</href>
</action>
</reference>
答案 2 :(得分:0)
你使用过<reference>
吗?
<reference name="head">
<action method="addLinkRel">
<rel>canonical</rel>
<href>http://fonts.googleapis.com/css?family=Dancing+Script</href>
</action>
</reference>
还要检查此link
答案 3 :(得分:0)
在我的代码中,我通常将其作为块插入。请参阅下面的google_font_material_icons:
<layout version="0.1.0">
<default translate="label" module="page">
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
<block type="page/html_head" name="head" as="head">
<action method="addCss"><stylesheet>css/style.css</stylesheet><params>media=screen,projection"</params></action>
<block type="core/text" name="google_font_material_icons">
<action method="setText"><text><![CDATA[<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons">]]></text></action>
</block>
</block>
...
我希望它有所帮助。