https://github.com/loadsys/metadata
CakePHP Metadata Plugin - Unmaintained
https://github.com/loadsys/metadata
Last synced: 7 months ago
JSON representation
CakePHP Metadata Plugin - Unmaintained
- Host: GitHub
- URL: https://github.com/loadsys/metadata
- Owner: loadsys
- Created: 2011-05-12T02:37:53.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-05-23T01:17:29.000Z (over 14 years ago)
- Last Synced: 2025-04-27T03:32:38.090Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 96.7 KB
- Stars: 9
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
#Metadata Plugin
##Description
CakePHP plugin to maintain meta tags for an application. These meta tags can be applied at a global level and be applied to every request, and overwrites can be applied per controller or controller action.
##Installation
Install the plugin
cd app/plugins
git clone git://github.com/joeytrapp/metadata.git
Include the component
// app/app_controller.php
var $components = array('Metadata.Metadata', /* All other components */);
The Metadata helper will get automatically included.
##Usage
To apply all of your metadata in a single location, create a metadata.php file in app/config:
// app/config/metadata.php
$metadata = array(
'_all' => array( // Global meta tags for all controllers
'description' => 'This is the site wide global description tag'
),
'controller_name' => array(
'_all' => array( // Global meta tags for all actions in controller
'description' => 'This is the description used for all actions in controller_name. Overwrites the site global description'
),
'action' => array( // Specific meta tags for this action
)
),
'pages' => array( // Pages controller meta tags
'_all' => array( // Meta tags for all static pages
),
'home' => array( // If controller is pages, the last pass param is used (file name)
'description' => array(
'content' => 'Home page description',
'charset' => 'UTF-8'
)
)
)
);
To apply metadata from within the controller, you can set a controller property called metadata
// app/app_controller.php
var $metadata = array(
'description' => 'Global description for this controller',
'action' => array(
'description' => 'Description for action only'
)
);
Metadata can also be added from within a controller action with a component method
function index() {
// other controller stuff
$this->Metadata->metadata('description', 'This is the description set from within the controller action');
// other controller stuff
}
Then to load all of the meta tags that were set use the Metadata.Metadata helper
// app/views/layouts/default.ctp
Metadata->meta(); ?>
Can also add additional meta tags from the view with the same helper method
Metadata->meta('description', 'Description meta tag applied from view'); ?>