1. Register the new module (we will call the module CMS and give the development company the name Acme):
In your magento\app\etc\modules directory create a file named Acme_All.xml with the following content:-
<?xml version="1.0"?>
<config>
<modules>
<Acme_Cms>
<active>true</active>
<codePool>local</codePool>
</Acme_Cms>
</modules>
</config>
2. Register the module (which will be implemented in the class
Acme_Cms_Block_Page) as being responsible for rewrite-ing the cms/page
block
In a magento\app\code\local\Acme\Cms\etc directory (you will need to
create it) create a config.xml file with the following content:-
<?xml version="1.0"?>
<config>
<global>
<blocks>
<cms>
<rewrite>
<page>Acme_Cms_Block_Page</page>
</rewrite>
</cms>
</blocks>
</global>
</config>
3. Change the original block logic (based on what is in app\code\core\Mage\Cms\Block\Page.php) to handle our CMS home page.
In a magento\app\code\local\Acme\Cms\Block directory create a file named Page.php with the content:-
<?php class Acme_Cms_Block_Page extends Mage_Cms_Block_Page{
protected function _prepareLayout(){
$page=$this->getPage();
//show breadcrumbs
if(Mage::getStoreConfig('web/default/show_cms_breadcrumbs') && ($breadcrumbs=$this->getLayout()->getBlock('breadcrumbs'))
&& ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_no_route'))){
$breadcrumbs->addCrumb('home',array('label'=>Mage::helper('cms')->__('Home'),'title'=>Mage::helper('cms')->__('Go to Home Page'),'link'=>Mage::getBaseUrl()));
if ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_home_page')){
$breadcrumbs->addCrumb('cms_page', array('label'=>$page->getTitle(), 'title'=>$page->getTitle()));
}
}
if($root=$this->getLayout()->getBlock('root')){
$root->addBodyClass('cms-'.$page->getIdentifier());
}
if($head=$this->getLayout()->getBlock('head')){
$head->setTitle($page->getTitle());
$head->setKeywords($page->getMetaKeywords());
$head->setDescription($page->getMetaDescription());
}
}
}
Be sure that you have enabled breadcrumbs for CMS pages [Config->Web->Default Pages->Show breadcrumbs for CMS pages =
Yes]
Reference: http://www.magentocommerce.com/boards/viewthread/49743/
No comments:
Post a Comment