2017 © Pedro Peláez
 

cakephp-plugin css-safe-slug

Converts a slug into a safe to use css class

image

davidyell/css-safe-slug

Converts a slug into a safe to use css class

  • Thursday, November 2, 2017
  • by davidyell
  • Repository
  • 1 Watchers
  • 0 Stars
  • 239 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

CakePHP-CssSafeSlug

In most web apps you will be using a slug to uniquely identify an article or item from the database. This gives you a clean way to access the item in the url. However, in CSS classes are not allowed to start with a number. This is a simple helper which will convert any slug which begins with a number into a safe string which can be used for a css class., (*1)

Looking for CakePHP 3? Try this, http://github.com/davidyell/CakePHP3-NumbersToWords, (*2)

Requirements

  • PHP 5.3.0+
  • Intl

Example

Article
  Title: "99 Ways to solve a puzzle"
  Slug: "99-ways-to-solve-a-puzzle"
  Unsafe css: "99-ways-to-solve-a-puzzle"
  Safe: "ninety-nine-ways-to-solve-a-puzzle"

Usage

You will need to put the code in your app/Plugin/CssSafeSlug, and load the plugin in your app/bootstrap.php using CakePlugin::load('CssSafeSlug');., (*3)

It is also available on Composer. composer require davidyell/css-safe-slug, (*4)

You can call the helper in your view., (*5)

<div class="article <?php echo $this->CssClass->convert($article['Article']['slug']);?>">

Handy extras

I couple this up with the CakeDC/Utils::Sluggable behaviour., (*6)

The Versions

02/11 2017

dev-master

9999999-dev

Converts a slug into a safe to use css class

  Sources   Download

The Requires

 

16/02 2015

0.1.3

0.1.3.0

Converts a slug into a safe to use css class

  Sources   Download

The Requires

 

15/08 2014

0.1.2

0.1.2.0

Converts a slug into a safe to use css class

  Sources   Download

The Requires

 

13/08 2014

0.1.1

0.1.1.0

Converts a slug into a safe to use css class

  Sources   Download

The Requires

 

09/05 2014

0.1.0

0.1.0.0

Converts a slug into a safe to use css class

  Sources   Download

The Requires