URL base em xml de atualização de layout de página cms
-
13-12-2019 - |
Pergunta
No momento, estou enfrentando problemas para definir o URL base no layout de página magento CMS.No momento estou fazendo assim, mas não estou obtendo o URL base:
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo>
<label>Home</label>
<title>Home</title>
<link> {{store url}} </link>
</crumbInfo>
</action>
Solução
Você provavelmente está usando a referência errada.Apenas o Mage_Page_Block_Html_Breadcrumbs
classe tem oaddCrumb
método.Exemplo:
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo>
<label>Home</label>
<title>Home</title>
<link>/</link>
</crumbInfo>
</action>
<action method="addCrumb">
<crumbName>CMS Page</crumbName>
<crumbInfo>
<label>CMS Label Page</label>
<title>CMS Title Page</title>
</crumbInfo>
</action>
</reference>
EDITAR:
Para obter informações dinâmicas para o novo miolo adicionado, reescreva Mage_Page_Block_Html_Breadcrumbs
.As migalhas são armazenadas em uma matriz como esta:
/**
* Array of breadcrumbs
*
* array(
* [$index] => array(
* ['label']
* ['title']
* ['link']
* ['first']
* ['last']
* )
* )
*
* @var array
*/
Criando o addCrumbCms
método:
function addCrumbCms($crumbName, $crumbInfo, $after = false)
{
$crumbInfo['link'] = Mage::getUrl() . Mage::getSingleton('cms/page')->getIdentifier();
$this->_prepareArray($crumbInfo, array('label', 'title', 'link', 'first', 'last', 'readonly'));
if ((!isset($this->_crumbs[$crumbName])) || (!$this->_crumbs[$crumbName]['readonly'])) {
$this->_crumbs[$crumbName] = $crumbInfo;
}
return $this;
}
E use o novo método na última migalha, como este:
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo>
<label>Home</label>
<title>Home</title>
<link>/</link>
</crumbInfo>
</action>
<action method="addCrumbCms">
<crumbName>CMS Page</crumbName>
<crumbInfo>
<label>CMS Label Page</label>
<title>CMS Title Page</title>
</crumbInfo>
</action>
</reference>
Observação:Crie uma extensão para fazer isso, não altere o núcleo.
Outras dicas
Eu tentei assim:
<reference name="root">
<action method="unsetChild"><alias>breadcrumbs</alias></action>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb">
<crumbName>Home</crumbName>
<crumbInfo>
<label>Home</label>
<title>Home</title>
<link>/</link>
</crumbInfo>
</action>
<action method="addCrumb">
<crumbName>Recipes</crumbName>
<crumbInfo>
<label>Recipes</label>
<title>Recipe Home Page</title>
<link>magenshop/recipe</link>
</crumbInfo>
</action>
<action method="addCrumb">
<crumbName>Current Page</crumbName>
<crumbInfo>
<label>Current Page</label>
<title>Current Page</title>
</crumbInfo>
</action>
</block>
</reference>
Mas meu / in para minha página inicial me leva à pasta raiz do projeto, não à página inicial do magento.