[eluser]kuroir[/eluser]
Code:
ciSEO: CodeIgniter Search Engine Optimization Library
---------------------------------------
This library is meant to help you when dealing with one of the most important
stages of development: SEO.
This library will help you with:
- Titles
- Keywords
- Descriptions
- Canonical
- Prev, Next, Start links
- Google, MSN and Yahoo Verification codes
- Word filtering for pronouns, prepositions. Used on keywords(optional)
This library will help you with XHTML Based SEO, however it wont help you with the
.htaccess optimizations. In the future (depending on how many ask for it) I'll add
a .htaccess rules generator with all the SEO.
Instructions:
---------------------------------------
To begin with the demo, all you need to do is copy the provided application folder
to your CI Installation and then access the demo via:
http://yoursite.com/index.php/seodemo
To begin using ciSEO you need to first edit your configuration file on
config/config_general.php
Then on your controller you need to load the following (as presented on the demo)
$this->load->library('seo');
$this->load->helper('url');
$this->load->config('config_general');
You need to laod them manually unless you want to autoload them. I did this to let
you choose without wasting time trying to load the helpers and configs again on the library file.
ciSEO has to ways to deal with the information:
1. Manual
This method will make you deal with everything on your own, which means more work:
echo $this->seo->title('My Page');
echo $this->seo->description('My Page Description, etc');
2. Automatic (Default)
You can still use the same methods as above, but instead of echoing them everything
will be saved as a string on a variable, and to print it you need to call output()
nethod.
With automatic mode the library will add any mandatory elements pulling the
information from your config file.
Mandatory: title, description, google vcode, msn vcode and yahoo vcode.
The easy way to set everything on automatic mode is via set() method:
$this->seo->set(array(
"title" => 'My Page',
"description" => 'My Page Description, etc',
));
And then printing the output using:
echo $this->seo->output();
Available Methods
---------------------------------------
public set($array):
Method for setting everything with one call, it only accepts an associative
array as parameter.
Allowed keys:
'title' => 'value'
'keywords' => 'value'
'description' => 'value'
'canonical' => 'value'
'start' => 'value'
'prev' => 'value'
'next' => 'value'
'google' => 'value'
'msn' => 'value'
'yahoo' => 'value'
public setKeywords($string):
Method for Keywords, it accepts strings and arrays. Once you pass a variable
it will filter words if enabled, remove everything but alphanumeric characters,
separate by commas, and limit to 150 characters.
@params mixed $string
public setTitle($string):
Method that sets the title by passing a string, it'll check the configuration
file for site_persistent_title and add the title at the end of the passed
string if enabled.
public setDescription(string):
Method for the setting the description, it sanitize the string and limits
the string to 150 characters.
public setCanonical($uri):
public setStart($uri):
public setNext($uri):
public setPrev($uri):
Method for setting X. It uses site_url() tu build a good url structure.
it accepts empty URI.
@params string $variable URI
public setGoogle($string):
public setMsn($string):
public setYahoo($string):
Method for Google Verification code. If on automatic mode there's no need
to explicitly call it, it'll be automatically included taking the info from
the config file.
private buildOutput($array):
Building Method
The parameter needs to be an associative array, tipe => value
public filterWords($string):
Method to filter words on a string. It's used to remove prepositions, pronouns,etc
used on setKeywords()
private sanitize($string):
Function to sanitize everything. This way you can add custom filters.
private buildUrl($string):
Builds the URL using base_url() or site_url().
public output():
If on automatic mode, checks for the $history array to verify that all
the mandatory methods have been called by the user and then returns the
output.
Todo:
---------------------------------------
- Use English Pronouns and Prepositions. Currently are in spanish.
- Build a .htaccess generator (should I do this?)
You can download it from github on:
http://github.com/kuroir/ciSEO
or on RAR:
http://exolimpo.com/ciSEO.rar
Any comment is welcome
!