Skip to content

Commit 59e109f

Browse files
authored
Merge pull request #570 from ExpressionEngine/modernizing-existing-addons
Modernizing existing addons
2 parents 1900ea1 + 109f2a7 commit 59e109f

File tree

8 files changed

+104
-7
lines changed

8 files changed

+104
-7
lines changed

docs/development/actions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
# Actions
1111

12+
TIP: If you are working with an existing add-on, we recommend you start with [Modernizing add-ons](development/modernizing-existing-add-ons.md)
13+
1214
[TOC]
1315

1416
## Overview

docs/development/addon-development-overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Here are some ideas of what you can accomplish with a custom add-on:
3232
These are just a few ideas of what you can do with custom add-ons. The possibilities are almost endless.
3333

3434
## Getting Started
35-
Getting started making an add-on is incredibly easy with the CLI. To begin making an add-on simply, use the `make:addon` command from the [CLI](/cli/intro.html).
35+
Getting started making an add-on is incredibly easy with the CLI. To begin making an add-on, simply use the `make:addon` command from the [CLI](/cli/intro.html).
36+
37+
TIP: If you are working with an existing add-on, we recommend you start with [Modernizing add-ons](development/modernizing-existing-add-ons.md)
3638

3739
```
3840
$ php system/ee/eecli.php make:addon
@@ -219,4 +221,4 @@ In the past, add-ons were often categorized based on their functionality. We ide
219221

220222
With the release of 6.4.x and 7.2.x this paradigm has been updated to reflect the idea that we are just creating add-ons, and those add-ons can have multiple types of functionality. The CLI has also been updated to make creating add-ons and adding functionality incredibly easy. We have also updated the docs to reflect the ideal workflow of creating an add-on.
221223

222-
While the latest changes shift our view of add-ons and how developers will create add-ons, you may still come across add-ons using the old methodology. We have left much of the old methods and structure in place in the core so that older add-ons will continue to work. However, we are choosing to not actively update the documentation for the old methods because we feel it's no longer in the best interest of the community to develop add-ons in this way. If you need to access how the docs once were regarding add-ons, you can reference the [legacy docs in GitHub](https://github.com/ExpressionEngine/ExpressionEngine-User-Guide/releases/tag/legacy-add-on-structure) (note that v7 and v6 were the same in these regards).
224+
While the latest changes shift our view of add-ons and how developers will create add-ons, you may still come across add-ons using the old methodology. We have left much of the old methods and structure in place in the core so that older add-ons will continue to work. However, we are choosing to not actively update the documentation for the old methods because we feel it's no longer in the best interest of the community to develop add-ons in this way. If you need to access how the docs once were regarding add-ons, you can reference the [legacy docs in GitHub](https://github.com/ExpressionEngine/ExpressionEngine-User-Guide/releases/tag/legacy-add-on-structure) (note that v7 and v6 were the same in these regards).

docs/development/automated-upgrading.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,20 @@ class My_awesome_plugin_upgrade {
3434
}
3535
3636
if(version_compare($version, '4.0.0', '=')) {
37-
// Run updates for upgrade to EE3
37+
// Run updates for upgrade to EE4
38+
}
39+
40+
if(version_compare($version, '5.0.0', '=')) {
41+
// Run updates for upgrade to EE5
3842
}
3943
44+
if(version_compare($version, '6.0.0', '=')) {
45+
// Run updates for upgrade to EE6
46+
}
47+
48+
if(version_compare($version, '7.0.0', '=')) {
49+
// Run updates for upgrade to EE7
50+
}
4051
}
4152
4253
}

docs/development/custom-template-tags.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lang: php
1212
-->
1313

1414
# Adding Template Tags
15+
TIP: If you are working with an existing add-on, we recommend you start with [Modernizing add-ons](development/modernizing-existing-add-ons.md)
1516

1617
[TOC]
1718

@@ -389,4 +390,4 @@ The current date is: November 15, 2022
389390
The current time is: 02:40 PM
390391
```
391392

392-
TIP: Of course, this is only the beginning of what you can do with variables in your tag. We created single variables here, but you can create pair variables and much more. For more information about this, and manipulating the tagdata in your plugin, check out the [Template Class](development/legacy/libraries/template.md).
393+
TIP: Of course, this is only the beginning of what you can do with variables in your tag. We created single variables here, but you can create pair variables and much more. For more information about this, and manipulating the tagdata in your plugin, check out the [Template Class](development/legacy/libraries/template.md).

docs/development/extensions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lang: php
1212
-->
1313

1414
# Extensions and Hooks
15+
TIP: If you are working with an existing add-on, we recommend you start with [Modernizing add-ons](development/modernizing-existing-add-ons.md)
1516

1617
[TOC]
1718

@@ -26,7 +27,7 @@ NOTE:Before adding an extension hook to your add-on, you need to already have an
2627
We can give our add-on the ability to hook into the core of ExpressionEngine by using the CLI:
2728

2829
```
29-
$ php system/ee/eecli.php make:extension-hook
30+
$ php system/ee/eecli.php make:extension-hook -i
3031
Let's implement an extension hook!
3132
What hooks would you like to use? (Read more: https://docs.expressionengine.com/latest/development/extensions.html) typography_parse_type_end
3233
What add-on is the extension hook being added to? [amazing_add_on]: amazing_add_on
@@ -35,6 +36,7 @@ Extension hook created successfully!
3536
3637
```
3738

39+
NOTE: If you are using the command above to add an extention to an existing add-on, please see the [Updating Existing Add-ons](development/modernizing-existing-add-ons.md)
3840

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

@@ -185,4 +187,4 @@ There will be rather popular hooks being used by multiple extensions and some ho
185187

186188
### `ee()->extensions->end_script`
187189

188-
Many extension hooks exist for the express purpose of totally controlling a page or script in the Control Panel. They are meant for redesigning the appearance of a form or perhaps usurping a script for processing form data. In those instances you want your extension to be the last thing called for that extension hook so that nothing else is processed after that point. The `ee()->extensions->end_script` exists solely for that purpose. If you set this value to TRUE, then once your extension is done being processed the execution of the hook is finished, as is the script that the extension hook is contained within.
190+
Many extension hooks exist for the express purpose of totally controlling a page or script in the Control Panel. They are meant for redesigning the appearance of a form or perhaps usurping a script for processing form data. In those instances you want your extension to be the last thing called for that extension hook so that nothing else is processed after that point. The `ee()->extensions->end_script` exists solely for that purpose. If you set this value to TRUE, then once your extension is done being processed the execution of the hook is finished, as is the script that the extension hook is contained within.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!--
2+
This source file is part of the open source project
3+
ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide)
4+
5+
@link https://expressionengine.com/
6+
@copyright Copyright (c) 2003-2023, Packet Tide, LLC (https://packettide.com)
7+
@license https://expressionengine.com/license Licensed under Apache License, Version 2.0
8+
-->
9+
10+
# Modernizing Existing Add-ons
11+
12+
13+
14+
The ExpressionEngine 7.2 release brought a new add-on development approach, which generates the majority of the add-on's needed files and structure. It also brings additional organization to how add-ons are developed.
15+
16+
NOTE: These changes do NOT break existing add-ons. The old development methodologies will still work. However once these changes are made the add-on will require ExpressionEngine 7.2+.
17+
18+
19+
The idea of an add-on _being_ a "plugin", "module", "extension", "fieldtype", etc. is no longer accurate. Instead, an add-on can include features such as template tags, actions, fieldtypes, or extensions.
20+
21+
To utilize the updated method for creating add-ons, you will need to make some small changes to your current add-ons. However, this does not mean that you need to completely convert your add-ons to the new method. After making these updates, you can continue using your existing add-ons and begin creating new ones using the updated method.
22+
23+
24+
25+
[TOC]
26+
27+
## Updating your mod.addon.php file
28+
In order to use the new approach, you will have to have your mod file use and extend the module add-on service. Your mod file will also need to add the protected variable $addon_name in the class
29+
30+
31+
```
32+
use ExpressionEngine\Service\Addon\Module;
33+
34+
class Amazing_add_on extends Module
35+
{
36+
protected $addon_name = 'amazing_add_on';
37+
38+
```
39+
40+
41+
## Updating your mcp.addon.php file
42+
43+
In order to use the new approach, you will have to have your mcp file use and extend the Mcp add-on service. Your mcp file will also need to add the protected variable $addon_name in the class
44+
45+
```
46+
use ExpressionEngine\Service\Addon\Mcp;
47+
48+
class Amazing_add_on_mcp extends Mcp
49+
{
50+
protected $addon_name = 'amazing_add_on';
51+
```
52+
53+
## Updating your ext.addon.php file
54+
55+
In order to use the new approach, you will have to have your ext file use and extend the Extension add-on service. Your ext file will also need to add the protected variable $addon_name in the class
56+
57+
```
58+
use ExpressionEngine\Service\Addon\Extension;
59+
60+
class Amazing_add_on_ext extends Extension
61+
{
62+
protected $addon_name = 'amazing_add_on';
63+
```
64+
65+
## Updating your upd.addon.php file
66+
67+
In order to use the new approach, you will have to have your upd file use and extend the Installer add-on service
68+
69+
```
70+
use ExpressionEngine\Service\Addon\Installer;
71+
72+
class Amazing_add_on_upd extends Installer
73+
{
74+
```
75+
## A Note on Plugins
76+
If your add-on is currently a plugin and you are looking to take advantage of the new add-on development methodologies, we recommend migrating your plugin methods (functions) to your mod file first. This can be done with a simple copy and paste.

docs/development/modules.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ lang: php
1212
-->
1313

1414
# Add Control Panel Pages To Your Add-On
15+
TIP: If you are working with an existing add-on, we recommend you start with [Modernizing add-ons](development/modernizing-existing-add-ons.md)
1516

1617
[TOC=2-3]
1718

@@ -519,4 +520,4 @@ ExpressionEngine includes both its own JavaScript library as well as the [The jQ
519520

520521
- After defining any JavaScript output, you must compile in order to display it:
521522

522-
ee()->javascript->compile();
523+
ee()->javascript->compile();

docs/toc_sections/_advanced_usage_toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@
168168
href: development/widgets.md
169169
#- name: REMOVE - Adding Text Formatting Options
170170
# href: development/text-formatting.md
171+
- name: Modernizing add-ons
172+
href: development/modernizing-existing-add-ons.md
171173
- name: Accessing the Database
172174
href: development/database-access.md
173175

0 commit comments

Comments
 (0)