Skip to content

Commit 80a896e

Browse files
author
Andy McCormick
committed
more updates and sidebar items
1 parent 20c9473 commit 80a896e

File tree

5 files changed

+125
-20
lines changed

5 files changed

+125
-20
lines changed
16.6 KB
Loading

docs/development/addon-development-overview.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Getting started making an add-on is incredibly easy with the CLI. To begin makin
3838
$ php system/ee/eecli.php make:addon
3939
Let's build your add-on!
4040
What is the name of your add-on? Amazing Add-On
41-
Add-on description? This add-on does amazing things!
41+
Add-on description? [Amazing Add-on description] This add-on does amazing things!
4242
Add-on version? [1.0.0]1.0.0
4343
Add-on author? ExpressionEngine Developer
4444
Add-on author URL? www.expressionengine.com
@@ -47,15 +47,10 @@ Your add-on has been created successfully!
4747
4848
```
4949

50-
This will create an add-on named Amazing Add-On in your `system/user/addons` folder with a file structure like below:
50+
This will create an add-on named Amazing Add-On in your `system/user/addons` folder with a skeleton file structure like below:
5151

5252
```
5353
amazing_add_on/
54-
┣ Module/
55-
┃ ┣ Actions/
56-
┃ ┃ ┗ ExampleAction.php
57-
┃ ┗ Tags/
58-
┃ ┗ ExampleTag.php
5954
┣ language/
6055
┃ ┣ english/
6156
┃ ┃ ┣ amazing_add_on_lang.php
@@ -64,7 +59,7 @@ amazing_add_on/
6459
┗ upd.amazing_add_on.php
6560
```
6661

67-
This is the starting point of an add-on and is enough to begin creating template tags, extension hooks, and much more! From here, you can add more functionality to your add-on depending on your needs.
62+
At this point, your add-on can't really do anything other than be installed. However, from here, you can add more functionality to your add-on via the CLI depending on your needs.
6863

6964
Here's a list of functionality that can be added to your add-on and the corresponding CLI command if applicable:
7065

@@ -96,6 +91,7 @@ amazing_add_on
9691
┃ ┣ TemplatePostParse.php
9792
┃ ┗ TypographyParseTypeEnd.php
9893
┣ Mcp
94+
┃ ┣ Sidebar.php
9995
┃ ┣ Index.php
10096
┃ ┗ Page2.php
10197
┣ Module
@@ -172,31 +168,51 @@ Reference [Adding Prolets](development/prolets.md) for more information on addin
172168
### The Add-on Icon File `icon.svg`
173169
The add-on icon folder is used both in the Add-on Manager and in the Dock on the front-end to distinguish your add-on from others.
174170

175-
### `/Extensions`
171+
### Extensions - `/Extensions`
176172
When we tell the CLI that we want to create an extension, classes are automatically created in the `Extensions` folder along with the above mentioned `ext.[addon_name].php` file. Interacting with hooks allows us to extend ExpressionEngine's functionality, thus we refer to these as "extensions".
177173

178174
TIP: Reference the [Extensions](development/extensions.md) section of the docs for more information on using extensions in your add-on.
179175

180-
### `Module/Actions`
181-
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.
176+
### Actions - `/Module/Actions`
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+
Reference [Adding Actions](development/actions.md) for more information on creating URL endpoints (actions) with your add-on.
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.
182183

183184
### `Module/Tags`
184-
The `Module/Tags` folder stores all the business logic for any template tags we create with our add-on.
185+
The `Module/Tags` folder stores all the business logic for any template tags we create with our add-on.
186+
Reference [Adding Template Tags](development/custom-template-tags.md) for more information on adding template tags with your add-on.
185187

186188
### `/views`
187189
The `views` folder contains all of our Control Panel views which will be used to render our add-on's control panel pages.
188190

189191
### `/language`
190-
The `language` folder contains all of our language files that will be used to display text on a page in whatever language is selected in the user’s account settings.
192+
The `language` folder contains all of our language files that will be used to display text on a page in whatever language is selected in the user’s account settings.
193+
Reference [Using Language Files](development/add-on-language-files.md) for more information on using language files with your add-on.
191194

192195
### `/database/migrations`
193196
The `/database/migrations` folder holds all migrations that will be ran on installation or updating of our add-on. Using the CLI, migrations can also be ran independently.
194197

195198
### `Model`
196-
The `Model` folder holds all models that we are creating with our add-on.
199+
The `Model` folder holds all models that we are creating with our add-on.
200+
Reference [Building Your Own Models](/development/services/model/building-your-own.md) for more information on creating your own models with your add-on.
197201

198202
### `widgets`
199203
The `widgets` folder holds all dashboard widgets we create with our add-on.
204+
Reference [Developing Dashboard Widgets](development/widgets.md) for more information on creating widgets with your add-on.
205+
206+
## Setting Default CLI Config Values
207+
208+
When creating an add-on via the CLI you will be asked for author and the author's URL. If you'd like to skip these questions when creating an add-on, you can set default values in your [config](/general/system-configuration-overrides.md#main-configuration-file) file like so:
209+
210+
```
211+
...
212+
$config['cli_default_addon_author'] = 'ExpressionEngine Developer';
213+
$config['cli_default_addon_author_url'] = 'https://expressionengine.com';
214+
...
215+
```
200216

201217
## A Word About Legacy Add-On Development
202218
In the past, add-ons were often categorized based on their functionality. We identified our add-on to ExpressionEngine as a fieldtype, extension, module, or plug-in. Thus there was never a straightforward process on structuring one add-on that contained all these categories in one.

docs/development/fieldtypes/fieldtypes.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ Adding a custom fieldtype to your add-on is easy with the `make:fieldtype` comma
2424

2525
```
2626
$ php system/ee/eecli.php make:fieldtype
27-
compatiblity
27+
Let's implement a fieldtype!
28+
What is the fieldtype name? Amazing Fieldtype
29+
What add-on is the fieldtype being added to? [amazing_add_on]: amazing_add_on
30+
Building fieldype.
31+
Fieldtype created successfully!
2832
```
2933

30-
Follow the prompts to complete the setup of your custom fieldtype.
34+
This will create a `ft.[fieldtype_name].php` in your add-on's folder. In the example above, this creates a file named `ft.amazing__fieldtype.php`.
3135

36+
```
37+
amazing_add_on
38+
...
39+
┣ ft.[fieldtype_name].php
40+
┗ ...
41+
```
3242

3343
## Basic File Structure
3444

35-
Once generated via the CLI a file named `ft.[addon_name].php` will created in your add-on's folder. All fieldtypes must inherit from the `EE_Fieldtype`.
45+
All fieldtypes must inherit from the `EE_Fieldtype` base class and they must provide an `$info` array with a name and version number.
3646

3747
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3848

@@ -59,7 +69,7 @@ Once generated via the CLI a file named `ft.[addon_name].php` will created in yo
5969
/* End of file ft.google_maps.php */
6070
/* Location: ./system/user/addons/google_maps/ft.google_maps.php */
6171

62-
NOTE: **Note:** All add-ons are required to have an [addon.setup.php file](development/addon-setup-php-file.md). This is where Fieldtypes can declare their compatibility with other Fieldtypes, allowing a site builder to switch an existing field to another compatible type, e.g. _text_ can be switched to _email_ and vice-versa. Please see [Fieldtype Compatibility Options](development/addon-setup-php-file.md#fieldtypes) for more details.
72+
NOTE: **Note:** Fieldtypes can declare their compatibility with other Fieldtypes in the `addon.setup.php` file, allowing a site admin to switch an existing field to another compatible type, e.g. _text_ can be switched to _email_ and vice-versa. Please see [Fieldtype Compatibility Options](development/addon-setup-php-file.md#fieldtypes) for more details.
6373

6474
NOTE: We also have [Example fieldtype with annotations](development/fieldtypes/example.md) for your reference.
6575

@@ -558,3 +568,7 @@ Here are the usage details for this function:
558568
A jQuery object of the field being affected by the current event is passed to the callback function.
559569

560570
NOTE: **Note:** Please refer to [Enhanced Fieldtype Features](development/fieldtypes/enhanced.md) page for advanced topics, such ad working with Live Preview, Entry Manager, Entry Cloning, File Picker and Conditional Fields.
571+
572+
## Do Something: Build A Fieldtype
573+
574+
For a complete fieldtype example see the [Google Maps Fieldtype example](/development/fieldtypes/example.md).

docs/development/modules.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,82 @@ If you needed to add more levels to your breadcrumbs you can chain them together
110110
This would add a breadcrumb that would look like `Add-Ons -> [Add-On Name] -> Settings -> Configuration`
111111

112112
### Sidebar
113-
TBD
113+
If your add-on has multiple Control Panel pages, a sidebar can be incredibly helpful for your users to easily navigate between pages. Sidebars can either be generated automatically or manually.
114+
115+
#### Automatically Generate Your Sidebar
116+
We can use the `make:sidebar` CLI command to generate a sidebar file for us.
117+
118+
```
119+
$ php system/ee/eecli.php make:sidebar
120+
What add-on is the sidebar being added to? [amazing_add_on]: amazing_add_on
121+
Building sidebar.
122+
Sidebar created successfully!
123+
```
124+
125+
This will create the file `Mcp/Sidebar.php` in your add-on's folder.
126+
127+
```
128+
amazing_add_on
129+
┣ Mcp/
130+
┃ ┣ Sidebar.php
131+
┗ ...
132+
```
133+
134+
**Note:** An add-on can only have one sidebar file.
135+
136+
Inside of our `Sidebpar.php` file we'll have the following:
137+
138+
```
139+
<?php
140+
141+
namespace ExpressionEngineDeveloper\AmazingAddOn\Mcp;
142+
143+
use ExpressionEngine\Service\Addon\Controllers\Mcp\AbstractSidebar;
144+
145+
class Sidebar extends AbstractSidebar
146+
{
147+
public $automatic = true;
148+
149+
/**
150+
* @param false $id
151+
* @return AbstractRoute
152+
*/
153+
public function process()
154+
{
155+
}
156+
}
157+
```
158+
159+
That's it! Our `Sidebar` class will scan our `Mcp` folder for all available Control Panel routes and automatically create respective entries in our sidebar. There's no need to add the sidebar to your Control Panel page as it will automatically be added when the page is rendered.
160+
161+
Example:
162+
163+
With an add-on folder like this:
164+
165+
```
166+
amazing_add_on
167+
┣ Mcp
168+
┃ ┣ Configurations.php
169+
┃ ┣ Settings.php
170+
┃ ┣ Licenses.php
171+
┃ ┣ Index.php
172+
┃ ┗ Sidebar.php
173+
┗ ...
174+
```
175+
176+
Would produce a sidebar in the Control Panel like this:
177+
178+
![control panel sidebar](_images/addon_sidebar_start.png)
179+
180+
181+
You can take this a step further by adjusting the following properties in your `Mcp` files to adjust how sidebar items are displayed:
182+
- **`protected $sidebar_title (string)`** - By default the sidebar link text is based on your route's name. This property will overwrite the text displayed for this route.
183+
- **`protected $sidebar_icon (string)`** - The Font Awesome icon you wish to display next to the sidebar link for this route.
184+
- **`protected $sidebar_is_folder (bool)`** -
185+
- **`protected $sidebar_is_list (bool)`** -
186+
- **`protected $exclude_from_sidebar (bool)`** - Exclude this route from the sidebar.
187+
- **`protected $sidebar_divider_before (bool)`** - Inserts a divider in the sidebar before
188+
- **`protected $sidebar_divider_after (bool)`** -
114189

115190
### Toolbar
116191

docs/development/prolets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ If the data returned is of *Array* type, it is being passed to ExpressionEngine
140140

141141
public function index()
142142
{
143-
if (ee('Request)->isPost()) {
143+
if (ee('Request')->isPost()) {
144144
//handle form submission
145145
return ee()->output->send_ajax_response(['success']);
146146
}

0 commit comments

Comments
 (0)