You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@license https://expressionengine.com/license Licensed under Apache License, Version 2.0
8
8
-->
9
9
10
10
# Developing Variable Modifiers
11
11
12
-
The add-ons can provide their own [variable modifiers](templates/variable-modifiers.md)
12
+
Add-ons can provide their own [variable modifiers](templates/variable-modifiers.md) for use in templates.
13
13
14
-
Each variable modifier needs be created as a separate file in `Modifiers` directory within add-on's own folder and registered in `addon.setup.php`.
14
+
Each variable modifier needs be created as a separate file in the `Modifiers` directory within the add-on's root folder, and registered in `addon.setup.php`.
15
15
16
-
The file name (which will also be PHP class name) should be the modifier's name with first letter capitalized.
16
+
The file name, which is also the PHP class name, should be the modifier's name with the first letter capitalized.
17
17
18
18
All modifier files are required to implement `ExpressionEngine\Service\Template\Variables\ModifierInterface`.
19
19
20
-
Each widget should have `namespace` definition, which should consist of the add-on's namespace as defined in `addon.setup.php` followed by `\Modifiers`.
20
+
Each modifier should have a `namespace` definition, which consists of the add-on's namespace as defined in `addon.setup.php` followed by `\Modifiers`.
21
21
22
-
Lastly, the modifier's name should be registered in `addon.setup.php`
22
+
Lastly, the modifier's name should be registered in `addon.setup.php`.
23
23
24
-
TIP: **Tip:** Modifiers provided by add-on can be called by their name as well as by their name prefixed with add-on's name and underscore. For example below we can use `{title:hacker}` and `{title:seo_hacker}` to achieve same result
24
+
TIP: **Tip:** Modifiers provided by add-ons can be called by their name as well as by their name prefixed with add-on's name and underscore. For example, below we can use `{title:hacker}` and `{title:seeo_hacker}` to achieve the same result.
25
25
26
26
### Example
27
27
28
-
Let's create `:hacker` modifier which would make text look geeky by converting some letters to numbers that look similarly. The modifier would be part of "Seeo" add-on.
28
+
Let's create the `:hacker` modifier, which would make text look geeky by converting some of the letters to similar looking numbers. This example modifier is part of the "Seeo" add-on.
29
29
30
30
<?php
31
31
32
32
/**
33
33
* namespace is required and must be add-on's namespace + 'Modifiers'
34
34
*
35
35
*/
36
-
<?php
37
-
38
36
namespace EEHarbor\Seeo\Modifiers;
39
37
40
38
use ExpressionEngine\Service\Template\Variables\ModifierInterface;
@@ -50,10 +48,10 @@ Let's create `:hacker` modifier which would make text look geeky by converting s
50
48
Next, we'll add the following to `addon.setup.php`
51
49
52
50
'modifiers' => array(
53
-
'hacker'
54
-
),
51
+
'hacker'
52
+
),
55
53
56
-
And now, let's call it in template.
54
+
And now, let's call it in a template.
57
55
58
56
{exp:channel:entries entry_id="1"}
59
57
<div class="title">
@@ -65,4 +63,4 @@ And now, let's call it in template.
0 commit comments