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/add-on-update-file.md
+66-54Lines changed: 66 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@
9
9
10
10
# Add-on Update File
11
11
12
+
[TOC]
13
+
12
14
## Overview
13
15
14
16
The `upd.[addon_name].php` file (commonly just called the `upd` file) is critical to ExpressionEngine knowing what to do with your add-on. Here we tell ExpressionEngine what actions to register, core hooks we want to use, database tables to update, and much more. We need to tell ExpressionEngine what to do when we install an add-on, update an add-on, and uninstall and add-on. Thankfully the CLI takes care of most of this for us.
@@ -63,8 +65,8 @@ class Amazing_add_on_upd extends Installer
63
65
The first thing you will notice in our `Amazing_add_on_upd` class is a list of properties that describe some specifics of our add-on to ExpressionEngine. There are two required properties to declare here:
64
66
65
67
```
66
-
public $has_cp_backend = 'y'; // Shows the option to see addon’s settings.
67
-
public $has_publish_fields = 'n'; // Whether module provides tab for entry edit page
68
+
public $has_cp_backend = 'y'; // Shows the option to see addon’s settings.
69
+
public $has_publish_fields = 'n'; // Whether module provides tab for entry edit page
68
70
```
69
71
70
72
## Install Your Add-On (`install()`)
@@ -77,23 +79,25 @@ The CLI automatically generates our install method. This method will ensure that
77
79
78
80
79
81
```
80
-
public function install()
81
-
{
82
-
parent::install();
82
+
public function install()
83
+
{
84
+
parent::install();
83
85
84
-
// create a database table
85
-
// notify mission control
86
-
// add publish tabs
86
+
// create a database table
87
+
// notify mission control
88
+
// add publish tabs
87
89
88
-
return true;
89
-
}
90
+
return true;
91
+
}
90
92
```
91
93
92
94
### Adding Publish Tabs
93
95
Optionally add the publish page tab fields to any saved publish layouts. This is ONLY used if the module adds a tab to the publish page and it requires the [`tabs()` function](#add-publish-tabs-with-your-add-on-tabs):
@@ -104,25 +108,27 @@ Optionally add the publish page tab fields to any saved publish layouts. This is
104
108
105
109
An optional function included only if your add-on adds a tab to the publish page. This function should return a multidimensional associative array: the top array key consisting of the tab name, followed by any field names, with each field having a variety of default settings. Note that when the fields are added to the publish page, they are namespaced to prevent variable collisions:
106
110
107
-
function tabs()
108
-
{
109
-
$tabs['tab_name'] = array(
110
-
'field_name_one'=> array(
111
-
'visible' => 'true',
112
-
'collapse' => 'false',
113
-
'htmlbuttons' => 'true',
114
-
'width' => '100%'
115
-
),
116
-
'field_name_two'=> array(
117
-
'visible' => 'true',
118
-
'collapse' => 'false',
119
-
'htmlbuttons' => 'true',
120
-
'width' => '100%'
121
-
),
122
-
);
123
-
124
-
return $tabs;
125
-
}
111
+
```
112
+
function tabs()
113
+
{
114
+
$tabs['tab_name'] = array(
115
+
'field_name_one'=> array(
116
+
'visible' => 'true',
117
+
'collapse' => 'false',
118
+
'htmlbuttons' => 'true',
119
+
'width' => '100%'
120
+
),
121
+
'field_name_two'=> array(
122
+
'visible' => 'true',
123
+
'collapse' => 'false',
124
+
'htmlbuttons' => 'true',
125
+
'width' => '100%'
126
+
),
127
+
);
128
+
129
+
return $tabs;
130
+
}
131
+
```
126
132
127
133
Be sure that you also update your [`install()` function](#adding-publish-tabs) to add your specified tabs.
128
134
@@ -138,22 +144,24 @@ The `update` method will run code when a user installs an update to our add-on.
138
144
|\$current |`string`| The last recorded version of the module in the `exp_modules` table |
139
145
| Returns | `Boolean` | `FALSE` if no update is needed, `TRUE` otherwise
140
146
141
-
public function update($current = '')
142
-
{
143
-
// Runs migrations
144
-
parent::update($current);
147
+
```
148
+
public function update($current = '')
149
+
{
150
+
// Runs migrations
151
+
parent::update($current);
145
152
146
-
// only run the update if the user is currently running a version less than 2.0
147
-
if (version_compare($current, '2.0', '<'))
148
-
{
149
-
// Do your update code here
150
-
// update database
151
-
// notify mission control of the update
152
-
}
153
+
// only run the update if the user is currently running a version less than 2.0
154
+
if (version_compare($current, '2.0', '<'))
155
+
{
156
+
// Do your update code here
157
+
// update database
158
+
// notify mission control of the update
159
+
}
153
160
154
161
155
-
return true;
156
-
}
162
+
return true;
163
+
}
164
+
```
157
165
158
166
## Uninstall Your Add-On (`uninstall()`)
159
167
The CLI automatically generates our uninstall method. This method will ensure that all extensions and actions declared above will be properly uninstalled. Similarly to installation, if you just need to ensure your actions and extensions are uninstalled, you can leave this method as is. However, you added custom functionality in the `install()` method, then you need to also ensure you clean up after yourself here.
@@ -162,19 +170,23 @@ The CLI automatically generates our uninstall method. This method will ensure th
| Returns |`Boolean`|`TRUE` if everything uninstalled properly, `FALSE` otherwise |
164
172
165
-
public function uninstall()
166
-
{
167
-
parent::uninstall();
173
+
```
174
+
public function uninstall()
175
+
{
176
+
parent::uninstall();
168
177
169
-
// remove my database tables
170
-
// remove any publish tabs
171
-
// turn off the lights
178
+
// remove my database tables
179
+
// remove any publish tabs
180
+
// turn off the lights
172
181
173
-
return true;
174
-
}
182
+
return true;
183
+
}
184
+
```
175
185
176
186
### Removing Tabs
177
187
Optionally delete any publish page tab fields saved in publish layouts. This is ONLY used if the module adds a tab to the publish page and it requires the `tabs()` function:
- Removed unnecessary indentation in "update version" sidebar item; [#4721](https://github.com/ExpressionEngine/ExpressionEngine/pull/4721)
33
+
- Add method to list indexes for a given table #4710 ; [#4571](https://github.com/ExpressionEngine/ExpressionEngine/pull/4710)
34
+
- Updated sidebar version section to be red with white color when theres a critical update [#4706](https://github.com/ExpressionEngine/ExpressionEngine/pull/4706)
35
+
- Decouple site query from log query when viewing CP logs [#4703](https://github.com/ExpressionEngine/ExpressionEngine/pull/4703)
36
+
- Updated drop-down filter controls to show as much of the filter value as possible [#4581](https://github.com/ExpressionEngine/ExpressionEngine/discussions/4581)
37
+
38
+
**Bug Fixes** 💃🐛
39
+
40
+
- Resolved an issue where numeric channel shortnames caused a js error in Pro Search settings [#4709](https://github.com/ExpressionEngine/ExpressionEngine/pull/4709)
41
+
- Resolved [#4576](https://github.com/ExpressionEngine/ExpressionEngine/issues/4576) where replace in Pro Search did not work with shared Grid fields
42
+
43
+
**Developers** 💻
44
+
45
+
- Added before_version_delete hook to entry versioning [#4694](https://github.com/ExpressionEngine/ExpressionEngine/pull/4694)
46
+
- Treat smart quotes more lightly when searching [#4359](https://github.com/ExpressionEngine/ExpressionEngine/discussions/4359)
0 commit comments