Showing posts with label SEO. Show all posts
Showing posts with label SEO. Show all posts

Saturday, February 23, 2013

Magento : Add SEO content in footer

There are following unique pages as category, product and cms pages.
Here, we will create an attribute for these pages as
1.CMS Page

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


<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_category', 'seo_footer_category_content', array(
                        'type'              => 'text',
                        'backend'           => '',
                        'frontend'          => '',
                        'label'             => 'SEO Footer Content',
                        '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();
?>
3.Product page

<?php
$installer = $this;
$installer->startSetup();
$installer->addAttribute('catalog_product', 'seo_footer_product_content', array(
                        'type'              => 'text',
                        'backend'           => '',
                        'frontend'          => '',
                        'label'             => 'SEO Footer Content',
                        '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();
?>

Now you can see corresponding attribute of product and category in admin.
But for cms page we have to add following code (use adminhtml_cms_page_edit_tab_meta_prepare_form event). Lets add below code in config.xml

<adminhtml>
    <events>
        <adminhtml_cms_page_edit_tab_meta_prepare_form>
            <observers>
                <bd_cms_page_edit_tab_meta>
                    <type>singleton</type>
                    <class>Bd_Attributes_Model_Observer</class>
                    <method>createCMSAttribute</method>
                </bd_cms_page_edit_tab_meta>
            </observers>
        </adminhtml_cms_page_edit_tab_meta_prepare_form>
    </events>
</adminhtml>
now create createCMSAttribute function in Bd/Attribures/Model/Observer.php file

public function createCMSAttribue($observer)
{
    $form = $observer->getEvent()->getForm();
    $fieldset = $form->getElement('meta_fieldset');
    $fieldset->addField('seo_footer_cms_conten', 'editor', array(
        'name' => 'seo_footer_cms_content',
        'label' => Mage::helper('cms')->__('SEO Footer Content'),
        'title' => Mage::helper('cms')->__('SEO Footer Content'),
        'style'     => '',
        'wysiwyg'   => false,
        'disabled'  => 0
    ));
}

To show the content in the footer we need to add the following code in footer.phtml

<?php
   $routeName=Mage::app()->getFrontController()->getRequest()->getRouteName();
   $currentCategory = Mage::registry('current_category');
   $currentProduct = Mage::registry('current_product');
   if ($currentProduct):
    echo $currentProduct->getSeoFooterProductContent();
   elseif ($currentCategory):
    echo $currentCategory->getSeoFooterCategoryContent();
   elseif( $routeName == 'cms'):
    $page = Mage::getSingleton('cms/page');  
    echo $page->getSeoFooterCmsContent();
  endif;
  ?>










Monday, December 19, 2011

SEO: Generic Metadata

    Title - Authors should use the title element to identify the contents of a document. Since users often consult documents out of context, authors should provide context rich page titles.

    <title></title>
    Author - Provide metadata to add semantic information to pages and sites. For example, use RDF to indicate the document's author.

    <meta name="author" content="">
    Description - Some search engines will index the META Description Tag found in the <head></head> section of your web pages. These indexing search engines may present the content of your meta description tag as the result of a search query.

    <meta name="description" content="">
    Contact Information - The ADDRESS element may be used by authors to supply contact information for a document and often appears at the beginning or end of a document.

    <address></address>
    Language Code - Language information is useful for accessibility, authoring tools, translation tools, font selection, page rendering, search, and scripting. There are four places where language information can be declared. One of those is in a meta element in the document head with the content attribute set tocontent-language.

    <meta http-equiv="content-language" content="en, fr, sp" />
    Explicit Language Annotations - In a language attribute on an element within the document.

    <p>The Spanish word for <em>thank you</em> is <em lang="es">gracias</em>.
    HTML Profile - The profile attribute of the HEAD specifies the location of a metadata profile. The value of the profile attribute is a URI.

    <head profile="http://www.example.com/profiles/html">