sbuzonas / cakephp-plugin-seo Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mcurry/seo
CakePHP plugin to simplify/automate basic SEO tasks (slugs, title, meta...)
This project forked from mcurry/seo
CakePHP plugin to simplify/automate basic SEO tasks (slugs, title, meta...)
/* * SEO CakePHP Component * Copyright (c) 2008 Matt Curry * www.PseudoCoder.com * http://github.com/mcurry/seo * * @author Matt Curry <[email protected]> * @license MIT * */ /* About */ The intent of this component is to automatically set relevent page titles and meta descriptions based on the content being sent to the view. It also assists in make pretty urls. /* Notes */ * This component is in a very early state. It probably won't work automatically in your application. * Patches for supporting a larger application base are appreciated. /* Instructions */ 1. Include the component in your app controller: var $components = array('Seo.Seo'); 2. The component will automatically try to pull relevant information for the title/meta description from: a. $Controller->data b. $Controller->viewVars 3. In your view the meta description is assigned to $meta_description_for_layout. 4. The page title will be $title_for_layout (CakePHP standard); 5. There is also a 2nd class "Seo" which has a static function for creating pretty urls. Say you were making a link to view a blog post and you wanted the link to be "/posts/view/12/this-is-the-blog-post-title" you would create the link: $html->link($post['Post']['name'], array('action' => 'view', Seo::slug($post['Post']))); The url function will automatically pull the id and title from $post and create the link. 6. In your controller you can leave the view function as is "function view($id) { ... }". CakePHP will automatically populate the $id and ignore the extra title param. 7. If you are worried about slug consitency you can use the verifySlug which will force a 301 redirect if the slug doesn't match. function view($id, $slug=null) { $post = $this->Post->read(null, $id); $this->Seo->verifySlug($post); $this->set('post', $post); } /* Short Urls */ If you need to post a link on twitter or some other service with limited characters simply remove the slug part of the link. For example: "/posts/view/12/this-is-the-blog-post-title" to "/posts/view/12" /* Even Shorter Urls */ Since the component works with Cake's built in routing system you can add a route like: Router::connect('/p/*', array('controller' => 'posts', 'action' => 'view')); All your links will be generated as: "/p/12/this-is-the-blog-post-title" and you can use "/p/12" as a short link
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.