A simple Cake3 plugin to slug fields and find records by slug.
PHP
Latest commit 7c6d9c1 Jan 21, 2016 @Xety Merge pull request #4 from lorenzo/patch-1
Make this plugin depend on the Cake ORM
Permalink
Failed to load latest commit information.
src/Model/Behavior Update the code to follow the CakePHP CS rules Dec 27, 2015
tests Update the code to follow the CakePHP CS rules Dec 27, 2015
.gitignore
.scrutinizer.yml Update scrutinizer Nov 4, 2014
.travis.yml
CONTRIBUTING.md First commit Nov 4, 2014
LICENSE
README.md
composer.json added keyword Jan 20, 2016
phpunit.xml.dist

README.md

Cake3 Sluggable

A simple Cake3 plugin to slug fields and find records by slug.

Build Status Coverage Status Scrutinizer Latest Stable Version Total Downloads License

Requirements

  • CakePHP 3.X

Installation

Run : composer require xety/cake3-sluggable:1.* Or add it in your composer.json:

"require": {
    "xety/cake3-sluggable": "1.*"
},

Usage

In your config/bootstrap.php add :

Plugin::load('Xety/Cake3Sluggable');

In your model initialize():

$this->addBehavior('Xety/Cake3Sluggable.Sluggable');

To use the custom finder :

$this->Users
    ->find('slug', [
        'slug' => 'your-slug-here',
        'slugField' => 'Users.slug'
    ]);

Configuration

  • field

    Default : title

    The field to slug :

    $this->addBehavior('Xety/Cake3Sluggable.Sluggable', [
            'field' => 'username'
        ]
    );
  • slug

    Default : slug

    The slug field name in your database :

    $this->addBehavior('Xety/Cake3Sluggable.Sluggable', [
            'field' => 'username',
            'slug' => 'slug_username'
        ]
    );
  • replacement

    Default : -

    The replacement characters used to replace space etc :

    $this->addBehavior('Xety/Cake3Sluggable.Sluggable', [
            'replacement' => '_'
        ]
    );

Contribute

Follow this guide to contribute