cialis online pharmacy generic xenical cheap cialis online cialis generic viagra online in canada buy cheap levitra online cialis without a perscription order viagra uk no prescription flagyl cheap generic levitra buying viagra in the uk cheap viagra approved cialis deltasone online buy viagra online without prescription non prescription cialis buy orlistat uk buy cialis in india prednisone 60 mg female viagra online buy viagra without prescription celebrex prescriptions buy cialis canada best prices viagra alternative to prednisone cheapest generic levitra levitra 5mg cheap viagra cialis on line buy xenical without prescription online accutane canadian health care prednisone no prescreption viagra online generic female viagra europe buy cialis low price cheap india viagra

Sluggable Behavior – Generate Unique Slug In CakePHP

On the web, “slug” is a short text used in a URL to identify and describe a resource. Sluggable behavior is cakephp model behaviors that allow us to generate unique slug. Sluggable Behavior who created by eberfreitas  is a simpler version of Mariano Iglesias’ Sluggable Behavior with a few add-ons. It’s basically the same thing but instead of implementing all the slug logic on the behavior, it just uses Cake’s Inflector::slug() method. With CakePHP 1.3, this method is really powerful and flexible.

To use it, just place the behavior file on the proper place (/app/models/behaviors/)and call it on the model you want to “slugify”:

var $actsAs = array(‘Sluggable’);

To use it, just place the behavior file on the proper place and call it on the model you want to “slugify”:  var $actsAs = array(‘Sluggable’);  By default, this will automatically create slugs from a field named “title” and place it under a field named “slug”. If you want, you can customize everything. Checkout the configuration keys:

var $actsAs = array(
‘Sluggable’ => array(
‘fields’ => ‘title’,
‘scope’ => false,
‘conditions’ => false,
‘slugfield’ => ‘slug’,
‘separator’ => ‘-‘,
‘overwrite’ => false,
‘length’ => 256,
‘lower’ => true



Related Posts

Read/Write An XML File Using CakePHP 1.3

Haml, Sass, Markdown, and CakePHP – Oh My!

CakePHP – jQuery Autocomplete Tutorial

How to Authenticate Users With Facebook Graph In CakePHP


  1. Jon L


    I wasn’t aware another sluggable behavior existed. Do you think I should change or it doesn’t matter. Also, do you know how to use this behavior to make pretty urls? Thank you

    • Mufti Ali


      Hi Jon, this behaviour allow You to create unique slug, you can also setting the maximum slug length. To implement this plugin is pretty simple. Put this behaviour in your behaviours folder (/app/models/behaviours/), and put this code to your model, eg user.php
      var $actsAs = array(
      'Sluggable' => array(
      'fields' => 'title',
      'scope' => false,
      'conditions' => false,
      'slugfield' => 'slug',
      'separator' => '-',
      'overwrite' => false,
      'length' => 256,
      'lower' => true