xety/cake3-sluggable

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

Installs: 9 411

Dependents: 1

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 3

Open Issues: 3

Type:cakephp-plugin

v1.2 2016-01-21 10:19 UTC

This package is auto-updated.

Last update: 2020-12-04 15:39:46 UTC


README

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