Monthly Archives: June 2012

Magento Set Title,Meta keywords and Meta Description

We can set the Title,Metakeywords and Meta description for our Custom Module.We can use the phtml or Php file for changing the title,Meta keywords and meta descriptionFor Example we have title and Template in our XML file we will change though our php or phtml file

Layout file

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="setTitle"><title>Custom Module Title</title></action>
        </reference>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
        </reference>
        <reference name="right">
            <block type="modulename/blockname" name="mymodule.sidebar" template="templatepath/yourfile.phtml"/>
        </reference>
    </default>
</layout>

 

we can use this code in any php or phtml file

 

$root = $this->getLayout()->getBlock('root');
$template = "page/2columns-right.phtml";
$root->setTemplate($template);
$head = $this->getLayout()->getBlock('head');

$head->setTitle("Your Title");
$head->setKeywords("Your, Keywords");
$head->setDescription("Your Description");

 

and refresh your title .keywords and description will be shown in your module page