Add SEO content in the magento footer

Add seo content in header

Do you know most of the search engines crawl from the bottom or footer of your pages?

The question is how can you add SEO friendly text in the footer of each and every page. It is easy regardless of whichever platform you are using.

Ok, let me explain how can you achieve this, it will definitely add a lot of value to your page ranking and conversion rate.

The first thing you need to do is identify the most unique pages of your website. In most of the e-commerce sites the main or unique pages are category, product and static or cms pages.

Once you have identified these pages, the next step would be to associate an attribute or a field with all these pages? If you are using Magento as your ecommerce platform then follow the steps below. Otherwise you got an idea how to achieve this, if you are still not sure, please comment on this post and we will be more than happy to help.

For Magento implementation, follow these steps -:

Create attribute for CMS pages -:

<?php $installer = $this; $installer->startSetup(); $installer->run(' ALTER TABLE '. $this->getTable("cms_page") . ' ADD column seo_footer text NULL; '); $installer->endSetup();
?>


Now to show the above attribute or field to the Meta tab of CMS pages, you need to use adminhtml_cms_page_edit_tab_meta_prepare_form event. Lets add the declaration of this event in our config.xml

<adminhtml> <events> <adminhtml_cms_page_edit_tab_meta_prepare_form> <observers> <scommerce_cms_page_edit_tab_meta> <type>singleton</type> <class>Scommerce_CMSAttributes_Model_Observer</class> <method>createCMSFields</method> </scommerce_cms_page_edit_tab_meta> </observers> </adminhtml_cms_page_edit_tab_meta_prepare_form> </events>
</adminhtml>

Now the event has been declared in config.xml we need to create our createCMSFields function in Scommerce/CMSAttribures/Model/Observer.php file

public function createCMSFields($observer)
{ $form = $observer->getEvent()->getForm(); $fieldset = $form->getElement('meta_fieldset'); $fieldset->addField('seo_footer', 'editor', array( 'name' => 'seo_footer', 'label' => Mage::helper('cms')->__('SEO footer text'), 'title' => Mage::helper('cms')->__('SEO footer text'), 'style' => 'height:16em;', 'wysiwyg' => false, 'disabled' => 0 ));
}

Now you should be able to see SEO footer text field in Meta tab (see below)

Ok, now you should be able to write unique SEO footer text for CMS pages, lets now do it for product and category pages.

For category and product pages it is much easier as you just need to create a sql set up file with the following content -:

<?php
$installer = $this; $installer->startSetup(); $installer->addAttribute('catalog_category', 'seo_footer', array( 'type' => 'text', 'backend' => '', 'frontend' => '', 'label' => 'SEO Footer', 'input' => 'textarea', 'class' => '', 'source' => '', 'global' => 0, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'default' => '', 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'unique' => 0, 'position' => 1, )); $installer->addAttribute('catalog_product', 'seo_footer', array( 'type' => 'text', 'backend' => '', 'frontend' => '', 'label' => 'SEO Footer', 'input' => 'textarea', 'class' => '', 'source' => '', 'global' => 0, 'visible' => 1, 'required' => 0, 'user_defined' => 1, 'default' => '', 'searchable' => 0, 'filterable' => 0, 'comparable' => 0, 'visible_on_front' => 0, 'unique' => 0, 'position' => 1, )); $installer->endSetup();

Until now we have the tool to add the content but we still need to show the content in the footer on the website. To show the content in the footer we need to add the following snippet.

<div id="seo"> <?php $routeName=Mage::app()->getFrontController()->getRequest()->getRouteName(); $currentCategory = Mage::registry('current_category'); $currentProduct = Mage::registry('current_product'); if ($currentProduct): echo $currentProduct->getSeoFooter(); elseif ($currentCategory): echo $currentCategory->getSeoFooter(); elseif( $routeName == 'cms'): $page = Mage::getSingleton('cms/page'); echo $page->getSeoFooter(); endif; ?>
</div>

That’s it! Hope you enjoyed this article and add value to your website!

Discover more from WHO WILL CARE eCommerce

Subscribe now to keep reading and get access to the full archive.

Continue reading