Entitle
, (*1)
Entitle is a Craft plugin which makes it easy to apply AP-style title capitalisation rules to the text on your website., (*2)
Requirements
Each release of Entitle is automatically tested against PHP 7.1 and above. It's also manually tested on the most recent version of Craft., (*3)
PHP 7.0 support
In theory, Entitle should be compatible with PHP 7.0. In practise, it's impossible to test this, because the Codeception dependency tree includes components which only work with PHP 7.1+., (*4)
Unfortunately there's nothing we can do about that., (*5)
Installation
To install Entitle, either search for "Entitle" in the Craft Plugin Store, or add it as a Composer dependency., (*6)
Here's how to install Entitle using Composer., (*7)
-
Open your terminal, and navigate to your Craft project:, (*8)
cd /path/to/project
-
Add Entitle as a project dependency:, (*9)
composer require experience/entitle
-
In the Control Panel, go to "Settings → Plugins", and click the "Install" button for Entitle, (*10)
Configuration
Entitle allows you to specify "protected" words, which are not subject to the AP capitalisation rules. This is useful for ensuring that acronyms, brand names, and the like are not modified., (*11)
After installing Entitle (as described above), navigate to its settings page, and enter your "protected" words as a comma-delimited string., (*12)
Usage
There are three ways to use Entitle:, (*13)
- As a Craft service.
- As a template variable.
- As a Twig filter.
Service
The Entitle service exposes a single method, capitalize
. The method accepts an input string, and returns the correctly-capitalised result., (*14)
// Result: 'Of Mice and Men'
Entitle::getInstance()->entitle->capitalize('of mice and men');
Template variable
Entitle exposes a single template variable, capitalize
. As with the service method of the same name, it accepts an input string, and returns the correctly-capitalised result., (*15)
// Result: 'Fear and Loathing in Las Vegas'
{{ craft.entitle.capitalize('fear and loathing in las vegas') }}
Twig filter
Entitle exposes a single Twig filter, entitle
., (*16)
// Result: 'The Hound of the Baskervilles'
{{ 'the hound of the baskervilles'|entitle }}