Skip to content

Commit 205a4d9

Browse files
author
Andy McCormick
committed
few more updates
1 parent 0f87e8e commit 205a4d9

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

docs/development/addon-development-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ TIP: Reference the [Extensions](development/extensions.md) section of the docs f
177177
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.
178178
Reference [Adding Actions](development/actions.md) for more information on creating URL endpoints (actions) with your add-on.
179179

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.
183183

184184
### `Module/Tags`
185185
The `Module/Tags` folder stores all the business logic for any template tags we create with our add-on.

docs/development/extensions.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ lang: php
1919

2020
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.
2121

22-
## Generate Our Extension Files
22+
## Creating Our Extension Files
2323

2424
We can give our add-on the ability to hook into the core of ExpressionEngine by using the CLI:
2525

2626
```
2727
$ php system/ee/eecli.php make:extension-hook
28+
2829
```
2930

30-
Follow the prompts to add an extension file to your add-on.
3131

3232
TIP: Files that interact with ExpressionEngine core hooks are referred to as "extensions" because they extend the functionality of ExpressionEngine.
3333

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.
3537

3638
```
3739
amazing_add_on
@@ -43,10 +45,6 @@ amazing_add_on
4345

4446
TIP: A single add-on can interact with as many hooks as you want.
4547

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-
5048
## `AddonName/Extensions`
5149
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.
5250

@@ -102,10 +100,40 @@ We know that we should expect the following parameters for this hook:
102100
We also know that we should be returning a string from our `process()` function.
103101

104102

105-
## Do Something
103+
## Do Something - Create An Extension Hook
106104

107105
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!)
108106

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:
118+
119+
```
120+
121+
<?php
122+
123+
namespace ExpressionengineDeveloper\AmazingAddOn\Extensions;
124+
125+
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.
136+
109137
```
110138
<?php
111139

docs/development/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ lang: php
1313

1414
# Add Control Panel Pages To Your Add-On
1515

16-
[TOC]
16+
[TOC=2-3]
1717

1818
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.
1919

0 commit comments

Comments
 (0)