2017 © Pedro Peláez
 

library mikl-seo

Seo module for ZF2

image

mikl/mikl-seo

Seo module for ZF2

  • Monday, October 22, 2012
  • by Mikl
  • Repository
  • 1 Watchers
  • 8 Stars
  • 85 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MiklSeo

This is a simple ZF2 module that optimize your "On-page" SEO based on a Zend\Navigation\Navigation instance., (*1)

Configuration

The module use by default the DefaultNavigationFactory of Zend\Navigation but you can use your own Navigation., (*2)

To do this, add the navigation key in the configuration, and specify your classname., (*3)

Also, MiklSeo use strategies to optimize your html for search engine., (*4)

MiklSeo\config\module.config.php :, (*5)

return array(
    'miklSeo' => array(
        'strategies' => array(
            'title' => array(
                'placement' => 'prepend'
            ),
            'meta' => array(),
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'MiklSeoNavigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', // feel free to change the factory
        ),
    ),
);

Define strategies in module.config.php under strategies key :, (*6)

  • key : string, Strategy classname
  • value : array, Parameters

By default, 2 strategies are available:, (*7)

Title :

Title strategy add title tag of your current html page if active page is found. prepend or append to the root title by specify placement key parameter., (*8)

return array(
    'miklSeo' => array(         
        'strategies' => array(  
            'title' => array(
                //'tag'             => 'myCustomTag',
                //'placement'       => 'appendOrPrepend',
                //'ignoreTag'       => 'ignoreSeoTag'
            ),
        ),
    ),
);

Default parameters:, (*9)

  • tag : title
  • placement : null
  • ignoreTag : ignoreTitleSeo

ignoreTag ignore strategy on the current node, (*10)

Meta :

Meta strategy add meta tag of your current html page if active page is found., (*11)

return array(
    'miklSeo' => array(         
        'strategies' => array(
            'meta' => array(
                //'tag'             => 'myCustomTag',
                //'ignoreTag'       => 'ignoreSeoTag'           
            ),

        ),
    ),
);

Default parameters:, (*12)

  • tag : meta
  • ignoreTag : noMetaSeo

ignoreTag bypass strategy on the current node., (*13)

Exemple :

From xml navigation file :, (*14)

<?xml version="1.0" encoding="UTF-8"?>
<configdata>
    <navigation>
        <default>
            <home>
                <label>Home</label>
                <title>Home</title>
                <uri>/</uri>
                <controller>index</controller>
                <action>index</action>  
                <route>home</route>
                <noTitleSeo>true</noTitleSeo>
                <meta>
                    <description>i am the description</description>
                    <keywords>my, keywords, list</keywords>
                    <google-site-verification>xxxx---x---x---x--xxxxxx-xx</google-site-verification>
                </meta>
                <pages>
                    <create>                
                        <label>create a disk list</label>
                        <title>create a disk list/title>
                        <route>create-disk</route>
                        <meta>
                            <description>another description.</description>
                            <keywords>another,keywords, here</keywords>                
                        </meta>
                    </create>
                </pages>
            </home>
        </default>           
    </navigation>   
</configdata>

Form this module.config.php file:, (*15)

return array(
    'miklSeo' => array(
        'strategies' => array(
            'title' => array(
                'placement' => 'prepend'
            ),
            'meta' => array(),
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'MiklSeoNavigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', // feel free to change the factory
        ),
    ),
);

Result :, (*16)

( Title have already defined before and value is : My Beauty Website ), (*17)

In home page :, (*18)

<title>My Beauty Website</title>
<meta>
    <description>i am the description</description>
    <keywords>my, keywords, list</keywords>
    <google-site-verification>xxxx---x---x---x--xxxxxx-xx</google-site-verification>
</meta>

In create page:, (*19)

<title>create a disk list - My Beauty Website</title>
<meta>
    <description>another description.</description>
    <keywords>another,keywords, here</keywords>
</meta>

Add your custom strategies :

You can create your custom seo strategy and add it in module.config.php To add a custom strategy your class must implement MiklSeo\Strategy\StrategyInterface, (*20)

interface StrategyInterface{

    public function run();

}

You can also herit MiklSeo\Strategy\AbstractStrategy to use default comportement:, (*21)

public function setTag($tag);
public function getTag();   
public function setIgnoreTag($ignoreTag);
public function getIgnoreTag();

And add it in module.config.php file, under strategy_plugins key :, (*22)

return array(
    'miklSeo' => array(
        'strategies' => array(
            'title' => array(
                'placement' => 'prepend'
            ),
            'meta' => array(),
        ),
         'strategy_plugins' => array(
            'My\Custom\Strategy\Implement\StrategyInterface' => array(
            )
        ),
    ),
    'service_manager' => array(
        'factories' => array(
            'MiklSeoNavigation' => 'Zend\Navigation\Service\DefaultNavigationFactory', // feel free to change the factory
        ),
    ),
);

The Versions

22/10 2012

dev-master

9999999-dev https://github.com/mickaelCOLLET/MiklSeo

Seo module for ZF2

  Sources   Download

The Requires

 

zf2 seo mikl