dev-master
9999999-dev https://github.com/mickaelCOLLET/MiklSeoSeo module for ZF2
The Requires
- php >=5.3
- zendframework/zendframework >=2.0.0
zf2 seo mikl
Wallogit.com
2017 © Pedro Peláez
Seo module for ZF2
This is a simple ZF2 module that optimize your "On-page" SEO based on a Zend\Navigation\Navigation instance., (*1)
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)
By default, 2 strategies are available:, (*7)
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)
ignoreTag ignore strategy on the current node, (*10)
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)
ignoreTag bypass strategy on the current node., (*13)
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>
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
),
),
);
Seo module for ZF2
zf2 seo mikl