Skip to content

Commit d0dd690

Browse files
author
Andy McCormick
committed
added note to create add-on first for each type of add-on functions
1 parent 205a4d9 commit d0dd690

File tree

10 files changed

+64
-14
lines changed

10 files changed

+64
-14
lines changed

docs/cli/creating-a-command.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The ExpressionEngine [Command Line Inferface (CLI)](/cli/intro.md) makes it simp
77

88
You can also build your own commands that will enable users to interact with your add-on or do other things inside of ExpressionEngine. Commands are created to live within add-ons, and are registered as part of the add-on process.
99

10+
NOTE:Before adding a custom CLI Command to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
11+
1012
## Generate Our Add-on
1113
We add custom commands to the CLI when our add-on is installed by using the CLI.
1214

docs/development/actions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
## Overview
1515
Actions in ExpressionEngine are URL endpoints that are reached with the `ACT` query parameter. An example of this might be `http://myamazingsite.com/?ACT=43` where 43 is the ID given to an action registered in the `exp_actions` database table. These actions are tied to methods in an add-on which can be used to accept input from forms or run some sort of other functionality defined in the add-on.
1616

17+
NOTE:Before adding an action to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
18+
1719
## How To Build An Amazing Action?
1820
To generate an action we use the CLI to add the action to our existing add-on named "Amazing Add-on".
1921

docs/development/custom-template-tags.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ TIP:If you are unfamiliar with Template Tags be sure to read the docs on [Expres
2121

2222
Creating your own custom template tags allows you to display dynamic data from your add-on anywhere you want, in any template.
2323

24+
NOTE:Before adding a template tag to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
25+
2426
## Creating Template Tags
2527
Tags are created via the CLI by using the `make:template-tag` command.
2628

docs/development/extensions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ 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+
NOTE:Before adding an extension hook to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
23+
2224
## Creating Our Extension Files
2325

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

docs/development/fieldtypes/example.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,34 @@ The snippets below were truncated for clarity. The full example fieldtype can be
1717

1818
[TOC]
1919

20-
## Installation
21-
22-
The google maps fieldtype is going to have 3 global settings. Latitude, longitude, and zoom. These will determine what the default map looks like. By returning an array from within install we can provide a default set of global settings.
20+
## Generate Fieldtype File
21+
Start by generating a custom fieldtype for your add-on using the `make:fieldtype` command.
22+
23+
```
24+
$ php system/ee/eecli.php make:fieldtype
25+
Let's implement a fieldtype!
26+
What is the fieldtype name? Amazing Fieldtype
27+
What add-on is the fieldtype being added to? [amazing_add_on]: amazing_add_on
28+
Building fieldype.
29+
Fieldtype created successfully!
30+
```
31+
32+
This will create a `ft.amazing__fieldtype.php` in your add-on's folder.
33+
34+
We'll now update the methods found within our fieldtype's class to provide our functionality:
35+
- `function install()`
36+
- `function display_global_settings()`
37+
- `function save_global_settings()`
38+
- `function display_settings()`
39+
- `function save_settings()`
40+
- `function display_field()`
41+
- `function replace_tag()`
42+
- `function replace_latitude()`
43+
- `function replace_tag_catchall()`
44+
45+
## Installation - `install()`
46+
47+
The google maps fieldtype is going to have 3 global settings. Latitude, longitude, and zoom. These will determine what the default map looks like. By returning an array from within our `install()` method we can provide a default set of global settings.
2348

2449
function install()
2550
{
@@ -35,7 +60,7 @@ The google maps fieldtype is going to have 3 global settings. Latitude, longitud
3560

3661
The installation method for this fieldtype does not create any additional tables, so no cleanup work needs to be done. The default `uninstall()` method provided by the EE_Fieldtype parent class will suffice. Most fieldtype methods have sensible defaults to help reduce duplicate code.
3762

38-
## Global Settings
63+
## Global - `display_global_settings()`
3964

4065
The installer sets the default global settings, but currently there is no way to change these from the control panel. We can use the `display_global_settings()` method to return the contents of the settings form. Having this method also enables the global settings link on the overview page.
4166

@@ -50,9 +75,9 @@ The installer sets the default global settings, but currently there is no way to
5075
return $form;
5176
}
5277

53-
Manually entering longitudes and latitudes is inconvenient so the final method in the example download also adds some javascript to let the user choose from a map.
78+
Manually entering longitudes and latitudes is inconvenient so the final method in the example download also adds some JavaScript to let the user choose from a map.
5479

55-
## Saving Global Settings
80+
## Saving Global Settings - `save_global_settings()`
5681

5782
In most instances saving the global settings is as easy as storing the `$_POST` array. Remember to include existing global settings if not everything can be changed.
5883

@@ -61,7 +86,7 @@ In most instances saving the global settings is as easy as storing the `$_POST`
6186
return array_merge($this->settings, $_POST);
6287
}
6388

64-
## Individual Settings
89+
## Individual Settings - `display_settings()`
6590

6691
The default map may not always be the desired choice for each map field, so on the regular settings page it will display a similar configuration screen. We will use the familiar [Shared Form View](development/shared-form-view.md) format to display our settings.
6792

@@ -127,7 +152,7 @@ The default map may not always be the desired choice for each map field, so on t
127152
));
128153
}
129154

130-
## Saving Individual Settings
155+
## Saving Individual Settings - `save_settings()`
131156

132157
Saving individual field settings works largely the same as saving global settings. Keep be aware that they are later merged with global settings, so they can override a global setting.
133158

@@ -142,7 +167,7 @@ If your fieldtype needs a wide style on the publish form, like Grid or a Textare
142167
);
143168
}
144169

145-
## Displaying the Field (Publish Page)
170+
## Displaying the Field On the Publish Page - `display_field()`
146171

147172
With all the settings set up, it can now be displayed on the publish screen. A key factor when you get to this stage is to decide in what format the data should be stored. Since all three available values in this case are numbers, this field will store them separated by pipes (`lang|lat|zoom`).
148173

@@ -173,9 +198,9 @@ With all the settings set up, it can now be displayed on the publish screen. A k
173198
return $hidden_input.'<div style="height: 500px;"><div id="map_canvas" style="width: 100%; height: 100%"></div></div>';
174199
}
175200

176-
## Rendering the Tag
201+
## Rendering the Tag - `replace_tag()`
177202

178-
Finally, the field needs a frontend display. For google maps this will almost exclusively be javascript.
203+
Finally, the field needs a frontend display. For google maps this will almost exclusively be JavaScript.
179204

180205
function replace_tag($data, $params = array(), $tagdata = FALSE)
181206
{
@@ -193,6 +218,8 @@ Finally, the field needs a frontend display. For google maps this will almost ex
193218

194219
Along with parameters a field can also provide tag modifiers to change its output. In the template these are called by adding a colon to the fieldname, followed by the modifier name. For example: `{myfield:latitude}`. The advantage that field modifiers have over parameters is that they can be used in conditionals.
195220

221+
These methods are not created by the CLI and need to be added as needed to your fieldtype's class.
222+
196223
Parsing the modifiers is identical to using the regular `replace_tag()` function. The method name must start with `replace_` followed by the modifier name.
197224

198225
function replace_latitude($data, $params = array(), $tagdata = FALSE)

docs/development/fieldtypes/fieldtypes.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ lang: php
1515

1616
[TOC]
1717

18+
## Overview
19+
ExpressionEngine ships with a range of fieldtypes already in place. However, perhaps you want to had your fieldtype that executes functionality differently than the fields that ship with ExpressionEngine. If so, then read below for how to create your own custom fieldtype.
20+
1821
TIP: For an overview of what a Fieldtype is, read the [Fieldtype Overview docs](/fieldtypes/overview.md).
1922

23+
NOTE:Before adding a fieldtype to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
2024

21-
## Generating A Custom Fieldtype
25+
## Creating A Custom Fieldtype
2226

2327
Adding a custom fieldtype to your add-on is easy with the `make:fieldtype` command.
2428

@@ -40,7 +44,7 @@ amazing_add_on
4044
┗ ...
4145
```
4246

43-
## Basic File Structure
47+
## Basic Fieldtype File Structure
4448

4549
All fieldtypes must inherit from the `EE_Fieldtype` base class and they must provide an `$info` array with a name and version number.
4650

docs/development/modules.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
0---
22
lang: php
33
---
44

@@ -15,10 +15,13 @@ lang: php
1515

1616
[TOC=2-3]
1717

18+
## Overview
1819
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.
1920

2021
NOTE:**NOTE:** Control Pages are what is rendered in the browser when visiting your add-on in the Add-on Manager. Control Panel Routes are what we had to our add-on that tells ExpressionEngine to render the pages. Think of it as we add a route to create a page.
2122

23+
NOTE:Before adding a Control Panel route to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
24+
2225
## Generate Your Route
2326

2427
If your add-on doesn't already have the required `Mcp` and `views` files, you can add a route to your add-on using the `make:mcp-route` command in the CLI.

docs/development/prolets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Prolets are add-on components that live in the [Dock](/advanced-usage/front-end/
1818
Here is an example of the add-on SEEO's prolet, which easily allows editors to edit SEO data for the entry they are currently viewing:
1919
![prolet example](_images/prolet_example.png)
2020

21+
NOTE:Before adding a Prolet to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
22+
2123
## Creating A Prolet
2224

2325
Creating a Prolet is straightforward using the `make:prolet` command in the CLI.

docs/development/tab-files.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Add-ons can also add tabs which are visible on in [Publish Layouts](control-pane
2323
Here is an example of the publish layout's tab for the Structure add-on:
2424
![structure tab](_images/structure_tab.png)
2525

26+
NOTE:Before adding a tab to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
27+
2628
## Creating The Tab File
2729
Tab files are not currently able to be generated through the CLI, thus you will need to manually create the file `tab.[addon_name].php` in the root of your add-on's folder.
2830

docs/development/widgets.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
[TOC]
1313

14+
## Overview
15+
1416
Along with the basic widgets which will come native with ExpressionEngine, each third-party add-on can provide multiple widgets to show pertinent information to users.
1517

1618
Widgets which are shipped with add-ons can have `.html` or `.php` extension and have to be placed into `widgets` sub-directory of the add-on. They are then installed automatically when the add-on is installed or updated. When using the CLI to generate a widget, a PHP widget will be created.
@@ -20,6 +22,8 @@ TIP:Users can also create widgets using ExpressionEngine template manager withou
2022
Here is an example of the Dashboard Widget shipped with the SEEO add-on:
2123
![SEEO dashboard widget](_images/dashboard_widget_example.png)
2224

25+
NOTE:Before adding a Dashboard Widget to your add-on, you need to already have an add-on in place. See [Building An Add-On: Getting Started](development/addon-development-overview.md#getting-started) for how to generate the starter files for your add-on.
26+
2327
## PHP Widgets
2428

2529
In order for an add-on to provide dashboard widgets, it needs to contain `widgets` folder inside its main directory, which will contain the widget files.

0 commit comments

Comments
 (0)