2

i have using the same url for different languages.

<reference name="head">
   <action method="addLinkRel">
      <rel>alternatve</rel>
      <href>https://www.example.com/</href>
      <hreflang>x-default</hreflang>
   </action>
   <action method="addLinkRel">
      <rel>alternatve</rel>
      <href>https://www.example.com/</href>
      <hreflang>de</hreflang>
   </action>
   <action method="addLinkRel">
      <rel>alternatve</rel>
      <href>https://www.example.com/top.html</href>
      <hreflang>de-de</hreflang>
   </action>
   <action method="addLinkRel">
      <rel>alternatve</rel>
      <href>https://www.example.com/</href>
      <hreflang>de-at</hreflang>
   </action>
   <action method="addLinkRel">
      <rel>alternative</rel>
      <href>https://www.example.com/</href>
      <hreflang>de-ch</hreflang>
   </action>
</reference>

But while using this code in category->custom design in manage categories. I'm geting only i url in the page. i check it in page source

<link rel="alternative" hreflang="de-ch" href="https://www.example.com/" />  
2

Try

 <reference name="head">
        <block type="core/text" name="rel.hreflang">
            <action method="setText"><text><![CDATA[<link rel="alternative" hreflang="x-default" href="https://www.example.com/" />]]></text></action>
            <action method="setText"><text><![CDATA[<link rel="alternative" hreflang="de" href="https://www.example.com/" />]]></text></action>
            ...
        </block>
 </reference>

I think the issue have something to do with $this->_data['items'][$type.'/'.$name] evaluating to the same array key.

To debug take a look at app/code/core/Mage/Page/Block/Html/Head.php

/**
 * Add Link element to HEAD entity
 *
 * @param string $rel forward link types
 * @param string $href URI for linked resource
 * @return Mage_Page_Block_Html_Head
 */
public function addLinkRel($rel, $href)
{
    $this->addItem('link_rel', $href, 'rel="' . $rel . '"');
    return $this;
}

/**
 * Add HEAD Item
 *
 * Allowed types:
 *  - js
 *  - js_css
 *  - skin_js
 *  - skin_css
 *  - rss
 *
 * @param string $type
 * @param string $name
 * @param string $params
 * @param string $if
 * @param string $cond
 * @return Mage_Page_Block_Html_Head
 */
public function addItem($type, $name, $params=null, $if=null, $cond=null)
{
    if ($type==='skin_css' && empty($params)) {
        $params = 'media="all"';
    }
    $this->_data['items'][$type.'/'.$name] = array(
        'type'   => $type,
        'name'   => $name,
        'params' => $params,
        'if'     => $if,
        'cond'   => $cond,
   );
    return $this;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.