CakePHP Search Engine Optimization Plugin
Please Support:
CakePHP SEO Plugin
Info:
- Version: 2.0
- Requirements: CakePHP 1.3/2.x
- Docs: CakePHP SEO Plugin API
- Article: CakePHP SEO Plugin Discussion and Examples
Watch:
Get it:
- Download Now
- git clone git://github.com/webtechnick/CakePHP-Seo-Plugin Seo
The Goal
I've been working on a few tools to help my good friend Doug Lay, an SEO expert, to optimize a CakePHP based application for search engines. I had two goals when developing this plugin1) An Easy, yet powerful, 301 redirecting tool complete with regular expression support and model callbacks to find correct slugs uris.
2) Dynamic Meta Tags customizable site wide on a global or micro scale, complete with regular expression support.
With these two goals in mind I developed the Search Engine Optimization plugin for CakePHP. A drop-in solution for most of what haunts the SEO Expert's nightmares.
Install and Setup
To install the plugin you'll need to clone/download the plugin into your app/plugins/seo directory and then run the schema into your database.
- cake schema create seo -plugin seo
Create the file app/config/seo.php with the following configurations like so:
- 'approverEmail' => 'nick@example.com',
- 'replyEmail' => 'noreply@example.com',
- 'parentDomain' => 'http://www.example.com'
- )
- );
SEO Redirect Quick Start Guide
1) Create the file app/app_error.php with the following- App::import('Lib','Seo.SeoUtil');
- SeoUtil::loadSeoError();
- class AppError extends SeoAppError {
- }
2) Then navigate to /admin/seo/seo_redirects to start adding 301 redirects.
SEO Meta Tags Quick Start Guide
1) Include the Seo.Seo helper in your app/app_controller.php file.2) Alter your layout to include the SEO Meta Tags in the head.
[geshi=html] Seo->metaTags(); ?>
3) Navigate to /admin/seo/seo_meta_tags to start adding Meta Tag data to your site
Advanced Callback Feature
For all what mod_rewrite cannot do for you, SEO plugin can!By defining a callback in the SEO Redirect you can do some very powerful things, most notably the ablity to do what .htaccess redirect can't, access your database to find the correct url instead of showing a 404.
A good example of this would be redirecting broken article urls with a id-slug combination. With a callback no matter what the slug, you can 301 redirect to the correct id-slug combination with one rule.
Callback Senorio
We have an article URL of http://www.example.com/article/123-slug where 123 is the id, and slug is the slug. What we'd like to do is 301 redirect any broken link with the id 123 to the correct URL with the correct slug. We could use wild card rules for every article, or we can just write one rule with a callback to Article. Here's how:URI: #/article/([0-9]*)(.*)#i
Redirect: /article/$1-{callback} Callback: Article::callbackFindSlugById
- //app/models/article.php
- function callbackFindSlugById($request){
- if($id){
- $this->id = $id;
- return $this->field('slug');
- }
- else {
- return false;
- }
- }
Note: If the callback returns false, the Redirect will be haulted.
This callback redirect rule will redirect any broken article link to the correct `id-slug` syntax.
Wiki Links
For more information, and complete documentation please visit the repository wiki on github.comWorking with Seo Redirects - https://github.com/webtechnick/CakePHP-Seo-Plugin/wiki/Seo-Redirects
Working with Seo Meta Tags - https://github.com/webtechnick/CakePHP-Seo-Plugin/wiki/Seo-Meta-Tags