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
Copy file name to clipboardExpand all lines: docs/development/addon-development-overview.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,9 +177,9 @@ TIP: Reference the [Extensions](development/extensions.md) section of the docs f
177
177
The `Module/Actions` folder stores all the business logic for any actions that we are adding to ExpressionEngine with our add-on. Each action will have a separate file and corresponding class created based on information provided in the `$actions` array in the `upd` file.
178
178
Reference [Adding Actions](development/actions.md) for more information on creating URL endpoints (actions) with your add-on.
179
179
180
-
### Control Panel Pages - `/Mcp`
181
-
The `Mcp` folder contains all the Control Panel pages and sidebar we create for our add-on.
182
-
Reference [Adding Control Panel Pages](development/modules.md) for more information on adding Control Panel pages with your add-on.
180
+
### Control Panel Routes - `/Mcp`
181
+
The `Mcp` folder contains all the Control Panel routes and we create for our add-on as well as our sidebar.
182
+
Reference [Adding Control Panel Pages](development/modules.md) for more information on adding Control Panel routes and pages with your add-on.
183
183
184
184
### `Module/Tags`
185
185
The `Module/Tags` folder stores all the business logic for any template tags we create with our add-on.
Copy file name to clipboardExpand all lines: docs/development/extensions.md
+36-8Lines changed: 36 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,19 +19,21 @@ lang: php
19
19
20
20
Within ExpressionEngine are what is known as "hooks"; little snippets of code in over 100 strategic places that allow the calling of third-party scripts that can rewrite and modify the inner workings of the program. By hooking into the core, you can do things like modify an entire Control Panel page, add/remove functionality, and modify the appearance of certain page elements. Hooks enable third party developers to modify aspects of ExpressionEngine without hacking the core.
21
21
22
-
## Generate Our Extension Files
22
+
## Creating Our Extension Files
23
23
24
24
We can give our add-on the ability to hook into the core of ExpressionEngine by using the CLI:
25
25
26
26
```
27
27
$ php system/ee/eecli.php make:extension-hook
28
+
28
29
```
29
30
30
-
Follow the prompts to add an extension file to your add-on.
31
31
32
32
TIP: Files that interact with ExpressionEngine core hooks are referred to as "extensions" because they extend the functionality of ExpressionEngine.
33
33
34
-
This will create an `ext[addon_name].php` file in our add-on along with an `Extensions` folder where we will build out the code we want to run when we interact with a core hook. Inside our `Extensions` folder the CLI will create a file with the same name as the core hook we plan to use.
34
+
This will create an `ext.[addon_name].php` file in our add-on along with an `Extensions` folder where we will build out the code we want to run when we interact with a core hook.
35
+
36
+
Inside our `Extensions` folder the CLI will create a file with the same name as the core hook we plan to use.
35
37
36
38
```
37
39
amazing_add_on
@@ -43,10 +45,6 @@ amazing_add_on
43
45
44
46
TIP: A single add-on can interact with as many hooks as you want.
45
47
46
-
## `ext.[addon_name].php`
47
-
48
-
Prior to ExpressionEngine 6.4.0 and 7.2.0, all code that was used to hook into the core was placed in our `ext.[addon_name].php` file. However, now that file mainly just extends the `Extension` service and routes ExpressionEngine to reference the `Extensions` folder in our add-on.
49
-
50
48
## `AddonName/Extensions`
51
49
Once we've added the ability to hook into the core with our add-on, an `Extensions` folder is created. The CLI will generate a class and a respective file for each core hook we wish to use.
52
50
@@ -102,10 +100,40 @@ We know that we should expect the following parameters for this hook:
102
100
We also know that we should be returning a string from our `process()` function.
103
101
104
102
105
-
## Do Something
103
+
## Do Something - Create An Extension Hook
106
104
107
105
Let's do something with our hook to demonstrate how this would work. We're going to continue working with the `typography_parse_type_end()` hook by replacing "e" with "EE" everywhere in our templates (because EE is amazing!)
108
106
107
+
Using the CLI to generate the extension hook:
108
+
109
+
```
110
+
$ php system/ee/eecli.php make:extension-hook
111
+
Let's implement an extension hook!
112
+
What is the extension hook name? Amazing Hook
113
+
What add-on is the extension hook being added to? [amazing_add_on]: amazing_add_on
114
+
Building Extension hook.
115
+
Extension hook created successfully!
116
+
```
117
+
This creates our `Extensions/TypographyParseTypeEnd.php` file for us. This file will initially look like this:
use ExpressionEngine\Service\Addon\Controllers\Extension\AbstractRoute;
126
+
127
+
class TypographyParseTypeEnd extends AbstractRoute
128
+
{
129
+
public function process()
130
+
{
131
+
}
132
+
}
133
+
```
134
+
135
+
All the functionality we want to include when our hook is executed needs to go inside our `process()` method. Here we are going to take the string passed in by the `TypographyParseTypeEnd()` core hook, replace all instances of `e` with `EE`, and then return the updated string.
Copy file name to clipboardExpand all lines: docs/development/modules.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ lang: php
13
13
14
14
# Add Control Panel Pages To Your Add-On
15
15
16
-
[TOC]
16
+
[TOC=2-3]
17
17
18
18
If you have ever used some of the add-ons that ship with ExpressionEngine such as [Block and Allow](/add-ons/blocklist.md) or [Pro Search](/add-ons/pro-search/overview.md), you will notice those add-ons have settings and configuration pages associated with them in the Control Panel. You add this functionality to your add-on using Control Panel Routes, also known as `Mcp` files. Whenever you add a Control Panel Route to your add-on using the CLI, an `Mcp` and `views` folder is automatically created for you, opening the door to creating your own Control Panel settings and pages.
0 commit comments