Pregunta

i'm trying to add my link to head section via my xml file, but nothing happens (magento 1.7.0.2)

<action method="addLinkRel"><rel>canonical</rel><href>http://fonts.googleapis.com/css?family=Dancing+Script</href></action>

please tell correct way.

¿Fue útil?

Solución

Maybe something like this, showing complete layout XML structure:

<?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>

The setText lets you do pretty much anything, and will be a safe bet for any third party js or css.

Otros consejos

<rel>canonical</rel> is used for adding a canonical link to the head.

For adding a stylesheet, please use:

<reference name="head">
    <action method="addLinkRel">
        <rel>stylesheet</rel>
        <href>http://fonts.googleapis.com/css?family=Dancing+Script</href>
    </action>
</reference>

do you have used <reference>?

<reference name="head">
    <action method="addLinkRel">
        <rel>canonical</rel>
        <href>http://fonts.googleapis.com/css?family=Dancing+Script</href>
    </action>
</reference>

also check this link

In my code I usually insert it as a block. See below the google_font_material_icons one:

<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>

....

I hope it helps.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top