CakePHP : signets remarquables du 07/07/2009 au 13/07/2009

13/07/2009  |  Publié dans cakephp

Quelques bonnes adresses CakePHP vues entre le 07/07/2009 et le 13/07/2009:

Cascading Dynamic Meta Tags and Page Titles in CakePHP 1.2
Une méthode pour gérer les meta données de page en cascade dans CakePHP, par Jamie Nay.
code.cakephp.org/cake3/branches/master
Cake3 ? On n'a pas même pas vu passer la 1.3, et encore moins le 2… Grosse surprise de la CakeFest#3 qui vient de s'achever à Berlin, l'annonce de cette nouvelle version de CakePHP basée sur PHP 5.3 et prenant en compte ses spécificités par Nate Abele lors de sa keynote…
Uploader (File Upload Plugin)
Signé Miles Johnson, un plugin très complet et très détaillé pour gérer les uploads de fichiers, et en particulier les images. Un de plus me direz-vous…
CakePHP Status Dashboard
Un plugin multifacette de Matt Curry qui permet de mettre en place très simplement un tableau de bord pour un site, avec monitoring système, Google Analytics… On peut faire ses propres widgets et c'est prometteur.

Plus sur ma page delicious  CakePHP.

Basic SEO and CakePHP (part 1)

15/03/2008  |  Publié dans cakephp, seo

(in English, for a change)

Pretty URLs

CakePHP easily produces URLS as http://www.mysite.com/post/view/456. Not too bad. But using the title of the post in the URL can slightly improve the relevancy of the link as seen by Google or other robots. For this, simply use the “Sluggable” Behaviours from Mariano Iglesias. It’s here. It helps generating string as “my-post-about-sea-and-shells” from the fields you want in your model. Very handy. A little bit of route tickering and you’ll have URLs such as http://www.mysite.com/post/view/my-post-about-sea-and-shells/

  1. Router::connect(‘/posts/:id/:slug’, array(‘controller’ => ‘posts’, ‘action’ => ‘view’), array(   ‘pass’ => array(‘id’, ’slug’),   ‘id’ => ‘[\d]+’ ));

quick tip : if you want your content to appear in Google News, the URLs of each post must include a three digit number. So you’d better leave the id as it is (and even pad it with extra zeros).

keywords and description

Yes, these are basic concerns: it’s better if each page has its own keywords and description. It may be overlooked by some, but the Google Webmaster Tools will still consider it as a flaw if many of your pages share the same description sentence. As to keywords, they are not taken into account by most robots, but they may be used by some links directories. In CakePHP, the layout (where HTML headers and the keywords and description tags are) is shared between pages (or at least sections, depending on your design), and we can’t imagine changing layout on a per-page basis… There’s one obvious function in the HtmlHelper that can be used to add metatags to your page. Here is how:

  1. // /views/news/view.php
  2. echo $html->meta(    ‘description’,    $news[‘News’][‘title’].‘ : ‘.$text->trim($news[‘News’][‘body’], 50),    array(‘type’ =&> ‘description’),    false);// … code to display the news body

The last parameter indicates whether you want the generated code to appear inline or between the head tags where you have echoed the $scripts_for_layout var. By digging into the source code, I found that the method addScript from the view class is used to achieve that, using the $scripts_for_layout variable. So it can be used directly, but to me the meta method is the obvious choice (so obvious it’s not even documented for the moment in the CakePHP documentation).

title

The title of the page is very important. Setting it on a per-page basis in CakePHP is easy. You just have to set it in your view using data passed by the controller. The variable to set is “pageTitle”.

  1. $this->pageTitle = $post[‘Post’][‘title’];

(to be continued… feel free to ad tips in the comments, of course!)

Archives

Liens au pif

  • mes photos
  • Mark Story
  • POPnews
  • Julien Bourgeois
  • Communauté française CakePHP
  • photos de bubu
  • snook.ca
  • Google Group CakePHP Fr
  • Le blog de Pierre
  • Cakebaker
  • blogcatalog
  • pictures of the north country
  • Formation CakePHP
  • Chez Trân
  • Pseudocoder
  • Derniers commentaires

    • Guillaume: Merci pour cette précision, Pierre, je vais aller voir ça.
    • Pierre Martin: Bonjour Guillaume, et merci encore une fois pourle lien vers mon article ! Juste...
    • Guillaume: De loin, on ne voyait pas très bien :)
    • Gabriiiel: Roy nous a remis un trophée… :D
    • Pierre MARTIN: Il y a aussi cet article de teknoid contenant un lien vers un plugin de recherche...
  • Derniers trackbacks