### Install Method Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/add-on-update-file.md
The install method is automatically generated and ensures that declared extensions and actions are installed. Use this method to add publish tabs, update the database, or perform other setup tasks.
```php
public function install()
{
parent::install();
// create a database table
// notify mission control
// add publish tabs
return true;
}
```
--------------------------------
### Add-on Setup File with Settings and Docs URL
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/addon-setup-php-file.md
This example demonstrates including optional keys like 'settings_exist' to indicate if the add-on has settings in the Add-On Manager and 'docs_url' for external documentation.
```php
'settings_exist' => TRUE
```
```php
'docs_url' => 'https://example.com/hello_world/docs'
```
--------------------------------
### Get Addon Installer Class
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Retrieve the fully qualified class name (FQCN) for the addon's installer (`upd.`) class.
```php
$addon->getInstallerClass();
```
--------------------------------
### Install Dependencies
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/README.md
Install all project dependencies using npm. This should be run in the root of the repository.
```bash
npm install
```
--------------------------------
### Install Cypress and Dependencies
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/cypress-tests.md
Run this command in the `tests/cypress` directory to install Cypress and its dependencies. This may take a while on the first run.
```bash
npm i
```
--------------------------------
### Run `update:prepare` and Start EE Upgrade
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/update-prepare.md
Prepare your ExpressionEngine site for an upgrade and automatically start the ExpressionEngine upgrade process after files have been moved.
```bash
php eecli.php update:prepare --upgrade-ee
```
--------------------------------
### Install an Add-on
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/addons.md
Install a new add-on. You can either be prompted to select an add-on or specify it directly using the --addon or -a option.
```bash
php eecli.php addons:install
```
```bash
php eecli.php addons:install --addon block_and_allow
```
--------------------------------
### Install Fieldtype Global Settings
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/fieldtypes/example.md
The install() method can return an array to set default global settings for the fieldtype. This example sets default latitude, longitude, and zoom values for a Google Maps fieldtype.
```php
function install()
{
// Somewhere in Oregon ...
return array(
'latitude' => '44.06193297865348',
'longitude' => '-121.27584457397461',
'zoom' => 13
);
}
```
--------------------------------
### Basic Channel Form Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/channels/channel-form/examples.md
A simple Channel Form setup for submitting data to a channel. Ensure the 'contact_form' channel exists.
```html
{exp:channel:form channel="contact_form" return="contact/thanks" }
{/exp:channel:form}
```
--------------------------------
### getExample
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/cp-form/field-sets.md
Retrieves the Field Set Example value.
```APIDOC
## getExample()
### Description
Returns the Field Set Example (`example`).
### Returns
- **null or string** - The value to use
```
--------------------------------
### Action Migration Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/actions.md
This migration file registers an action with ExpressionEngine, specifying the class, method, and CSRF exemption status. It is run during add-on installation and uninstallation.
```php
make('Action', [
'class' => 'Amazing_add_on',
'method' => 'AmazingAction',
'csrf_exempt' => false,
])->save();
}
/**
* Rollback the migration
* @return void
*/
public function down()
{
ee('Model')->get('Action')
->filter('class', 'Amazing_add_on')
->filter('method', 'AmazingAction')
->delete();
}
}
```
--------------------------------
### Example: Enable the extension if disabled
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/models/addon-extension.md
This example shows how to check if an extension is disabled and then call the `enable()` method if necessary.
```APIDOC
### Enable the extension if disabled
```php
$method = ee('Model')
->get('Extension')
->filter('class', 'My_extension_class_ext')
->first();
if ($method->enabled !== 'y') {
$method->enable();
}
```
```
--------------------------------
### Set Field Set Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/cp-form/field-sets.md
Provides an example text for the Field Set. This method supports chaining.
```php
$field_set->setExample('Example: some_value');
```
--------------------------------
### Simple Layout Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/templates/layouts.md
This example demonstrates a basic layout structure for a website, including header and footer elements, with the main content inserted via `{layout:contents}`.
```html
News Site
{layout:contents}
```
--------------------------------
### Show field if 'Content' has any value OR 'SEO Title' is 'Example'
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/control-panel/field-manager/conditional-fields.md
This example uses OR logic, making the field visible if either the 'Content' field has any value OR the 'SEO Title' field is exactly 'Example'.
```html
```
--------------------------------
### Running Migrations for All Addons
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/migrate.md
Execute database migrations for all installed add-ons.
```bash
php eecli.php migrate --addons
```
```bash
php eecli.php migrate:addon --all
```
--------------------------------
### Get Installed Addon Version
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Retrieve the version string of an installed addon. Returns NULL if the addon is not installed.
```php
$addon->getInstalledVersion();
```
--------------------------------
### Example Member Import XML
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/general/member-import-xml-format.md
This is a basic example of the XML structure for importing members, including username, screen name, password, and email. It demonstrates different password types (md5 and sha1).
```xml
brettbBrett Bretterson653132ffd94b986bf2bb806b3c67d190brett@example.comrobrRobert Robertson1b4395b877794a16a7f4db5747380dbaafc7ff18robert@example.com
```
--------------------------------
### Basic Add-on Setup File Structure
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/addon-setup-php-file.md
This is the fundamental structure of an addon.setup.php file, returning an associative array with essential add-on information. All required keys must be present.
```php
'Example, Inc',
'author_url' => 'https://example.com',
'name' => 'Hello World',
'description' => 'Displays a friendly "Hello world!" message.',
'version' => '2.0.0',
'namespace' => 'Example\HelloWorld'
);
```
--------------------------------
### Basic Pagination Setup
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/pagination.md
Instantiate the pagination service with the total item count and render it using a CP URL object.
```php
$base_url = ee('CP/URL', 'publish/edit');
$pagination = ee('CP/Pagination', $total_count)
->render($base_url);
```
--------------------------------
### Get Installed Addons
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Retrieve an array containing only the installed addon objects. This is useful for operations that should only affect or consider addons currently active on the system.
```php
ee('Addon')->installed();
```
--------------------------------
### Build Documentation
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/README.md
Generate the static HTML documentation. This command builds the entire user guide.
```bash
npm run build
```
--------------------------------
### Configure .htaccess for Subdirectory Installation
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/installation/best-practices.md
When ExpressionEngine is installed in a subdirectory (e.g., `https://example.com/myeesite/`), you may need to adjust the `RewriteRule` to account for the sub-directory. This example shows how to remove the leading slash before `index.php`.
```apache
RewriteRule ^(.*)$ index.php/$1 [L]
```
--------------------------------
### Example .env.php for Database and Base URL
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/advanced-usage/env-support.md
Manage database connection settings and Base URL using environment variables in `.env.php`. Ensure comments use `#`.
```php
#.env.php
#URLs
BASE_URL=http://mysite.test/
#DATABASE SETTINGS
DB_HOSTNAME=db
DB_DATABASE=db
DB_USERNAME=db
DB_PASSWORD=db
DB_PORT=3306
```
--------------------------------
### Get Current Field Group Count
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/fieldtypes/fluid.md
Outputs the 'count' of the current field group, starting at 1.
```html
{fluid_content:count_group}
```
--------------------------------
### Get All Addons
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Retrieve an array containing all addon objects. This method is useful for iterating through all installed and available addons.
```php
ee('Addon')->all();
```
--------------------------------
### Get ExpressionEngine Configuration Value
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/cypress-tests.md
Retrieve the current value of a configuration item using `cy.eeConfig()`. This example fetches the `site_url`.
```javascript
cy.eeConfig({ item: 'site_url' })
```
--------------------------------
### Serve Local Documentation
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/README.md
Serve a local copy of the built documentation using http-server. The site will be available at http://127.0.0.1:8080/build/.
```bash
npx http-server -o
```
--------------------------------
### Basic Model Fetching
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/model/fetching.md
Use `ee('Model')->get()` to start a query and `all()` to retrieve a Collection. Chaining calls is common for brevity.
```php
$builder = ee('Model')->get('Template');
$templates = $builder->all();
```
```php
$templates = ee('Model')->get('Template')->all();
```
--------------------------------
### Initial Setup: wysihat(options)
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/control-panel-js/wysihat-api.md
Creates a new instance of the WysiHat editor on a textarea element. This is the main public method for initializing the editor.
```APIDOC
## Initial Setup: wysihat(options)
### Description
Creates a new instance of the editor on a textarea.
### Method
`wysihat(options)`
### Parameters
#### Options
- **options** (object) - Optional - Configuration object for the editor.
- **buttons** (array) - Optional - An array of button names to include in the toolbar.
### Request Example
```javascript
$(\'textarea\').wysihat({
\'buttons\': [\'bold\', \'italic\', \'underline\']
});
```
```
--------------------------------
### Get Text-Based Selection Offsets
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/control-panel-js/wysihat-api.md
Retrieves the current selection within the editor as an ordered pair of text-based start and end offsets. Note that these are not HTML-based.
```javascript
selection.get();
```
--------------------------------
### Example config.php using .env.php variables
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/advanced-usage/env-support.md
Configure ExpressionEngine settings like base URL and database connection using environment variables from `.env.php`.
```php
// system/user/config.php
array(
'hostname' => $_ENV['DB_HOSTNAME'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'dbprefix' => 'exp_',
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
'port' => $_ENV['DB_PORT'],
),
);
$config['show_ee_news'] = 'y';
// EOF
```
--------------------------------
### Create and Render a View
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/view.md
Instantiate a view using `ee('View')->make()` and render it with data using the `render()` method. The view file should be a plain .php file in the add-on's `views` folder.
```php
$view = ee('View')->make('addon_name:member/profile');
$output = $view->render(array(
'member' => $current_member
));
```
--------------------------------
### List All Add-ons
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/addons.md
Use this command to view all add-ons available in your ExpressionEngine system.
```bash
php eecli.php addons:list
```
--------------------------------
### String Length Modifier
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/templates/language.md
Modifiers allow for common formatting without plugins. This example uses the 'length' modifier to get the character count of the 'excerpt' variable.
```html
{excerpt:length}
{!-- Outputs: 217 --}
```
--------------------------------
### Set Encryption Key
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/config/config.md
The secret key used by the Encrypt service to protect sensitive data. It is set during installation. Refer to the troubleshooting guide for generating new keys.
```php
$config['encryption_key'] = '26791dcd5c7cc9e569cc05b16b96235985cc9f03';
```
--------------------------------
### Create a View Instance
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/view.md
Create a new view instance by calling `make()` on the core view service. Pass the path to the view file, prefixed with the add-on's folder name.
```php
$view = ee('View')->make('addon_name:member/profile');
```
--------------------------------
### Get Field Count Within Group
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/fieldtypes/fluid.md
Outputs the 'count' of the current field within its group. For example, in a group of five fields, the fourth field would have a value of '4'.
```html
{fluid_content:count_in_group}
```
--------------------------------
### Get a Fluid Field by the Field ID
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/models/fluid-field.md
This example demonstrates how to retrieve fluid field data associated with a specific entry and fluid field ID, ordered by their display order.
```APIDOC
## Get a Fluid Field by the Field ID
### Description
Retrieves fluid field data for a given entry and fluid field ID, ordered by their display order.
### Method
```php
ee('Model')
->get('fluid_field:FluidField')
->filter('entry_id', 4)
->filter('fluid_field_id', 5)
->order('order')
->all();
```
```
--------------------------------
### Run `update:prepare` Interactively
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/update-prepare.md
Use this command to interactively prepare your ExpressionEngine site for an upgrade. No additional flags are required for interactive mode.
```bash
php eecli.php update:prepare
```
--------------------------------
### HTML Widget Structure
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/widgets.md
Example of an HTML widget. It must start with the `{widget}` tag, which accepts `title`, `class`, and `width` parameters. The content can include any ExpressionEngine template tags.
```html
{widget class="widget--support" title="ExpressionEngine Support" width="half"}
Get direct, fast, unlimited support from the same team that builds your favorite CMS.
```
--------------------------------
### Create Action CLI Prompt
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/actions.md
Example of the command-line interface prompts when creating a new action, specifying the action name and the add-on it belongs to.
```bash
$ php system/ee/eecli.php make:action --install
What is the action name? ExampleAction
What add-on is the action being added to? [amazing_add_on,...]: amazing_add_on
```
--------------------------------
### Upgrade Configuration Sample
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/installation/upgrading-from-ee2.md
This sample `upgrade.config.php` file allows advanced configuration for the EE upgrade process. It includes variables for setting paths, version information, and controlling file movement.
```php
'',
// Set our temporary caching directory
'temp_directory' => 'tmp',
// Here we'll set some path variables. Include a trailing slash
'old_base_path' => '',
'new_base_path' => '',
'old_public_path' => '',
'new_public_path' => '',
// Should the upgrader move the current system path. This is best used when
// upgrading from EE2 to the current version. The installer will
// automatically build your new file structure. Include a trailing slash.
'should_move_system_path' => false,
'old_system_path' => null,
'new_system_path' => null,
// Should the upgrader move the current theme path. This is best used when
// upgrading from EE2 to the current version. The installer will automatically
// build your new file structure. Include a trailing slash.
'should_move_theme_path' => false,
'old_theme_path' => null,
'new_theme_path' => null,
// Should the upgrader move your current template files. This is best used when
// upgrading from EE2 to the current version. The installer will automatically
// build your new file structure. Include a trailing slash.
'should_move_template_path' => false,
'old_template_path' => '',
'new_template_path' => '',
// Upgrade EE
'upgrade_ee' => false,
'run_preflight_hooks' => false,
'run_postflight_hooks' => false,
// CUSTOM HOOKS
// During the upgrader process, we'll run a preflight and postflight
// Here you can include functions that will run during those calls
'preflight_hooks' => [
// 'hook_name' => function() {
// echo "Hello";
// },
],
'postflight_hooks' => [
],
// Upgrade map
// If you have custom config files (i.e. Master Config) or custom paths,
// Use this to map the appropriate folders. Otherwise, we'll try and
// load these via the standard EE paths.
'upgrade_map' => [
'config_path' => '',
'database_path' => '',
'config_file' => '',
'database_file' => '',
'template_path' => '',
'index_file' => 'index.php',
'admin_file' => 'admin.php',
'index_file_old' => 'index-old.php',
'admin_file_old' => 'admin-old.php',
],
];
```
--------------------------------
### Display File Size of Image Manipulations
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/file.md
If image manipulations are defined, you can get the file size of a specific manipulation by appending its Short Name to the tag. For example, `{file_size:small}` for the 'small' manipulation.
```html
{file_size:small}
```
```html
{file_size:small:human}
```
```html
{file_size:small:human_long}
```
--------------------------------
### Configurable Email Contact Form
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/email.md
An example of a typical contact form setup with parameters for user recipients, specific recipients, and character set. It also demonstrates using member variables and current time for form fields.
```html
{exp:email:contact_form user_recipients="no" recipients="admin@example.com" charset="utf-8"}
Support Form
{/exp:email:contact_form}
```
--------------------------------
### MSM Example .env.php with Site-Specific Settings
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/advanced-usage/env-support.md
Configure ExpressionEngine for MSM by prefixing environment variables with site short names in `.env.php`. Comments must use `#`.
```php
#.env.php
#SITE-SPECIFIC SETTINGS
default_site.BASE_PATH=/home/sites/mysite.test/
default_site.BASE_URL=http://mysite.test/
second_site.BASE_PATH=/home/sites/anothersite.test/
second_site.BASE_URL=http://anothersite.test/
#DATABASE SETTINGS
DB_HOSTNAME=db
DB_DATABASE=db
DB_USERNAME=db
DB_PASSWORD=db
DB_PORT=3306
```
--------------------------------
### Forgot Password Form Tag with Parameters and Error Handling
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/member/forgot-password.md
A comprehensive example of the forgot password form tag, demonstrating the use of parameters for customization and inline error display. This setup is useful for integrating with form validation and error handling features.
```html
{exp:member:forgot_password_form
return="member/forgot-password/sent"
inline_errors="yes"
password_reset_url="member/reset-password"
email_template="member/email-password-reset"
}
{if errors}
{/if}
{/exp:member:forgot_password_form}
```
--------------------------------
### Starter Add-on Update File
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/add-on-update-file.md
This is the basic structure of an add-on update file generated by the CLI. It includes essential methods for installation, updates, and uninstallation.
```php
array(
'hostname' => $_ENV['DB_HOSTNAME'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'dbprefix' => 'exp_',
'char_set' => 'utf8mb4',
'dbcollat' => 'utf8mb4_unicode_ci',
'port' => $_ENV['DB_PORT'],
),
);
$config['show_ee_news'] = 'y';
// EOF
```
--------------------------------
### List Installed Fieldtypes
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/fieldtypes-list.md
Filters the list to show only fieldtypes from installed add-ons.
```bash
php eecli.php fieldtypes:list --installed
```
```bash
php eecli.php fieldtypes:list -i
```
--------------------------------
### Example Add-on Tag Usage
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/guidelines/in-app-documentation.md
Demonstrates the basic structure for documenting an add-on tag. This format is converted into a textarea for easy copying and pasting within ExpressionEngine.
```html
{exp:addon:method}
Put a typical code example here.
You can use code fencing or indented code blocks.
It will be converted to a textarea in ExpressionEngine for each copying and pasting.
{/exp:addon:method}
```
--------------------------------
### List Installed Add-ons
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/addons.md
Filter the add-on list to show only those that are currently installed.
```bash
php eecli.php addons:list i
```
```bash
php eecli.php addons:list installed
```
--------------------------------
### Action Creation CLI Prompts
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/actions.md
Example of prompts and responses when using the CLI to create a new action. This defines the action's name and the add-on it belongs to.
```bash
php system/ee/eecli.php make:action
What is the action name? ExampleAction
What add-on is the action being added to? amazing_add_on
Action created successfully!
```
--------------------------------
### Create a New Add-on with CLI
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/addon-development-overview.md
Use the `make:addon` command to generate the basic file structure for a new add-on. This command prompts for add-on details and creates the necessary files and folders.
```bash
$ php system/ee/eecli.php make:addon
Let's build your add-on!
What is the name of your add-on? Amazing Add-On
Add-on description? [Amazing Add-on description] This add-on does amazing things!
Add-on version? [1.0.0]1.0.0
Add-on author? ExpressionEngine Developer
Add-on author URL? www.expressionengine.com
Let's build!
Your add-on has been created successfully!
```
--------------------------------
### Show field if 'Content' has any value AND 'SEO Title' is 'Example'
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/control-panel/field-manager/conditional-fields.md
This example demonstrates combining two conditions using AND logic. The field will only appear if both the 'Content' field has any value and the 'SEO Title' field is exactly 'Example'.
```html
```
--------------------------------
### Activate Action on Creation Flag
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/actions.md
Use the `--install` or `-i` flag with the `make:action` command to automatically register the action in the `exp_actions` table immediately after creation.
```bash
php system/ee/eecli.php make:action --install
```
--------------------------------
### Update .env.php Install Mode
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/config-management.md
Set the `EE_INSTALL_MODE` variable in `.env.php` to control the installation mode.
```bash
php eecli.php config:env -e EE_INSTALL_MODE -v FALSE
```
--------------------------------
### Initialize Provider with Prefix
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/architecture.md
Create a Provider instance, which wraps the core dependency container and automatically enforces a given prefix for service registration and retrieval.
```php
$prefix = 'myaddon';
$provider = new Provider($dependencies, $prefix);
```
--------------------------------
### Get GET Parameter
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/request.md
Retrieve a `$_GET` parameter from the request. Returns false if the variable is not found.
```html
{exp:request:get name="my-var"}
```
--------------------------------
### Creating a Basic CP URL
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/url.md
This example demonstrates how to create a simple Control Panel URL using the CP/URL service. The service automatically appends the session ID when necessary.
```APIDOC
## Creating a Basic CP URL
### Description
Builds a Control Panel URL for a specific path.
### Method
```php
ee('CP/URL', 'publish/create/1');
```
### Parameters
#### Path Parameters
- **path** (String) - The path of the URL (e.g., 'publish/create/1').
```
--------------------------------
### Sidebar Service Usage Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/sidebar.md
Demonstrates how to instantiate the Sidebar Service and add various elements like items, dividers, headers, and lists to build a custom sidebar.
```APIDOC
## Sidebar Service Usage Example
This example shows how to use the `Sidebar` service to construct a control panel sidebar.
### Code
```php
// Instantiate the Sidebar Service
$sidebar = ee('CP/Sidebar')->make();
// Add a simple item
$item = $sidebar->addItem(lang('new'), ee('CP/URL', 'addons/settings/fortune_cookie/create'));
$item->withIcon('truck'); // Add an icon
$item->isActive(); // Mark as active
// Add a divider
$sidebar->addDivider();
// Add a header with a basic list
$header = $sidebar->addHeader('Settings');
$basic_list = $header->addBasicList();
$basic_item = $basic_list->addItem($text, $url);
$basic_item->asDeleteAction(); // Mark as a delete action
// Add a header with a folder list
$folder_list = $header->addFolderList($name);
$folder_item = $folder_list->addItem($text, $url)
->withEditUrl($url)
->withRemoveConfirmation($msg)
->identifiedBy($id);
$folder_item->asDefaultItem(); // Mark as default item
// Add a folder list directly to the sidebar
$folder_list_direct = $sidebar->addFolderList($name);
```
```
--------------------------------
### Check for Addon Installer
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Determine if an addon has an installer (`upd.`) file. Returns TRUE if it does, FALSE otherwise.
```php
$addon->hasInstaller();
```
--------------------------------
### Incorrect Constructor Method Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/guidelines/general.md
An example of an incorrect constructor method that does not use the `__construct()` magic method.
```php
class SuperClass {
function SuperClass() // does not use __construct()
{
}
}
```
--------------------------------
### EE_Fieldtype::install()
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/fieldtypes/fieldtypes.md
Installs the fieldtype and sets initial global settings. Can return an array of global variables.
```APIDOC
## EE_Fieldtype::install()
### Description
Installs the fieldtype and sets initial global settings. Can return an array of global variables.
### Returns
- `Void`
```
--------------------------------
### Check if Addon is Installed
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Determine if a specific addon is currently installed on the ExpressionEngine system. Returns a boolean value.
```php
$addon->isInstalled();
```
--------------------------------
### Add-on Setup File for Plugin Typography
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/addon-setup-php-file.md
Use this key to specify if your add-on provides a plugin that should be available as a text formatter in ExpressionEngine's Channel Fields.
```php
'plugin.typography' => TRUE
```
--------------------------------
### Get Direct Child by Name
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/tree-datastructure.md
Jump directly to a child node by its unique name using the `get()` method.
```php
$child1 = $node->get('child1');
```
--------------------------------
### Run `update:prepare` with Explicit Paths
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/update-prepare.md
Prepare your ExpressionEngine site for an upgrade by specifying the old and new base paths for your site. This is useful when your site directories are not in the default locations.
```bash
php eecli.php update:prepare --old-base-path=/var/www/old-site --new-base-path=/var/www/new-site
```
--------------------------------
### Get GET or POST Parameter
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/request.md
Retrieve a `$_POST` or `$_GET` parameter from the request. Returns false if the variable is not found.
```html
{exp:request:get_post name="my-var"}
```
--------------------------------
### Set Calendar Start Day
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/channels/calendar.md
Defines the starting day of the week for the calendar display. Accepts 'sunday' through 'saturday'.
```html
start_day="sunday"
```
--------------------------------
### Preorder Traversal Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/tree-datastructure.md
Illustrates the output of a preorder traversal, visiting the current node before its children.
```text
root
child1
subchild1
subchild2
child2
```
--------------------------------
### Set Forum Installation Status
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/general/system-configuration-overrides.md
This configuration variable is automatically enabled when the Discussion Forum module is installed. The default value is 'y'.
```php
$config['forum_is_installed'] = 'y';
```
--------------------------------
### Configure admin.php for a New Site
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/msm/overview.md
When setting up a new site in MSM, you need to copy and modify the `admin.php` file for that site. Update the `$system_path` to point to the main installation's system folder and set `$assign_to_config` variables for the site's name and control panel URL.
```php
$system_path = '../domain1.com/system/';
$assign_to_config['site_name'] = 'domain2_short_name';
$assign_to_config['cp_url'] = 'https://domain2.com/admin.php';
```
--------------------------------
### Perform Actions Start Hook
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/extension-hooks/module/simple-commerce.md
This hook is called after a purchase is recorded but before ExpressionEngine's default processing begins. Use it to execute custom logic before standard purchase actions.
```php
ee()->extensions->universal_call('simple_commerce_perform_actions_start', $this, $query->row());
if (ee()->extensions->end_script === TRUE) return;
```
--------------------------------
### Moblog Email Content Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/moblog.md
This is a basic example of email content for the Moblog module, including text and a file attachment.
```text
Here's a quick picture of the train station this morning on the way to work.
Notice the guy selling flowers? He's been there every morning like clockwork for the last 2 years.
He's always cheerful and actually has some pretty nice flowers.
```
--------------------------------
### List All CLI Commands
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/list.md
Run this command to see a comprehensive list of all available core and add-on commands.
```bash
php eecli.php list
```
--------------------------------
### Create a Custom CLI Command
Source: https://context7.com/expressionengine/expressionengine-user-guide/llms.txt
Demonstrates the structure for creating a custom command-line interface (CLI) command in ExpressionEngine. Commands are registered in `addon.setup.php` and logic resides in the `handle()` method.
```bash
# CLI commands are registered in addon.setup.php and generated via the EE CLI scaffolder.
# The handle() method contains the command logic; arguments and options are declared in $commandOptions.
```
--------------------------------
### Define Entry ID Range Start
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/channels/entries.md
Use `entry_id_from` to specify the starting entry ID for a range of entries to display.
```html
entry_id_from="20"
```
--------------------------------
### Incorrect Method Naming Examples
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/guidelines/general.md
Examples of improper method naming, including lack of descriptiveness, incorrect casing, and excessive verbosity.
```php
function fileproperties() // not descriptive, not camelCase
```
```php
function file_properties() // not descriptive and not camelCase
```
```php
function get_file_properties() // Better! But still not camelCase
```
```php
function getTheFilePropertiesFromTheFile() // wordy
```
--------------------------------
### Create and Customize Sidebar Items
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/sidebar.md
Demonstrates how to instantiate the Sidebar Service, add items with icons and active states, add dividers and headers, and create basic and folder list items with various options.
```php
// The Control Panel's left sidebar is built with the Sidebar Service:
$sidebar = ee('CP/Sidebar')->make();
// You can add items:
$item = $sidebar->addItem(lang('new'), ee('CP/URL', 'addons/settings/fortune_cookie/create'));
// Items can have an icon:
$item->withIcon('truck');
// Items may be marked as active:
$item->isActive();
// You can add dividers:
$sidebar->addDivider();
// You can add a header:
$header = $sidebar->addHeader('Settings');
// Header's may have a list. A list may be a basic list or a folder list:
$basic_list = $header->addBasicList();
$folder_list = $header->addFolderList($name);
// Lists have items:
$basic_item = $basic_list->addItem($text, $url);
$folder_item = $folder_list->addItem($text, $url)
->withEditUrl($url)
->withRemoveConfirmation($msg)
->identifiedBy($id);
// Folder list items may also be marked as default:
$folder_item->asDefaultItem();
// Basic list items may also be marked as a delete action:
$basic_item->asDeleteAction();
// You can add a folder list directly to a sidebar without a header:
$folder_list = $sidebar->addFolderList($name);
```
--------------------------------
### Generate Add-on Interactively
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/make-addon.md
Use this command to be interactively prompted for add-on details like name, description, version, author, and author URL. This is useful for creating a new add-on step-by-step.
```bash
$ php system/ee/eecli.php make:addon
Let's build your add-on!
What is the name of your add-on? Amazing Add-On
Add-on description? [Amazing Add-on description] This add-on does amazing things!
Add-on version? [1.0.0]1.0.0
Add-on author? ExpressionEngine Developer
Add-on author URL? www.expressionengine.com
Let's build!
Your add-on has been created successfully!
```
--------------------------------
### Example: Change the name of the called method
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/models/addon-extension.md
This example demonstrates how to retrieve an extension model, change its `method` property, and save the changes.
```APIDOC
### Change the name of the called method
```php
$method = ee('Model')
->get('Extension')
->filter('class', 'My_extension_class_ext')
->first();
$method->method = 'my_new_method_name';
$method->save();
```
```
--------------------------------
### Generate and Display Suggestions
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/pro-search/tags.md
This example demonstrates how to generate suggestions for a specific keyword and display them, including a fallback message if no suggestions are found. The `keywords` and `keywords:lang` parameters are used to specify the search term and its language.
```html
{exp:pro_search:suggestions keywords="jongle" keywords:lang="en" limit="1"}
Did you mean {suggestion}?
{if no_suggestions}No suggestions found.{/if}
{/exp:pro_search:suggestions}
```
--------------------------------
### Get a Channel Field Group
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/models/channel-field-group.md
Retrieves a specific Channel Field Group by its ID. Use `.first()` to get the model instance.
```php
ee('Model')->get('ChannelFieldGroup', 2)->first();
```
--------------------------------
### Implementing a Subscriber for PubSub
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/event.md
Demonstrates how to create a subscriber by implementing the `Subscriber` interface and defining `getSubscribedEvents()` and event handler methods (e.g., `on`).
```php
use ExpressionEngine\Service\Event\Subscriber;
class Button extends UIElement implements Subscriber {
public function getSubscribedEvents()
{
return array('click');
}
public function onClick()
{
echo 'clicked';
}
}
```
--------------------------------
### Update ExpressionEngine via EECLI
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/installation/updating.md
Use this command to update your ExpressionEngine installation through the command line interface. Ensure you have EECLI installed and configured.
```bash
php eecli.php update
```
--------------------------------
### Configure Cypress Environment
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/cypress-tests.md
Copy the example environment file to create your own `cypress.env.json`. This file stores sensitive information like site URL and database credentials required for Cypress to connect to ExpressionEngine.
```bash
cp cypress.env.example.json cypress.env.json
```
--------------------------------
### Comment Author Link Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/comment/entries.md
This example demonstrates how to create a link to a commenter's member profile using the `{author_id}` and `{author}` variables.
```html
{author}
```
--------------------------------
### Pro Search Shortcut Usage
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/pro-search/tags.md
Example of how to display a list of search shortcuts, with basic conditional logic for list formatting.
```html
{exp:pro_search:shortcuts group_id="1"}
{if count == 1}
{/if}
{/exp:pro_search:shortcuts}
```
--------------------------------
### Moblog Email Overrides Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/add-ons/moblog.md
This example demonstrates how to use overrides for authentication, categories, entry body, and location within a Moblog email.
```text
AUTH:johnsmith:mysecretword
{category}3,6{/category}
{field:body format="xhtml"}
Here's a quick picture of the train station this morning on the way to work.
Notice the guy selling flowers? He's been there every morning like clockwork for the last 2 years.
He's always cheerful and actually has some pretty nice flowers.
{/field:body}
{field:location format="none"}Train Station{/field:location}
```
--------------------------------
### Adding a Confirmation Modal
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/modal.md
This example demonstrates how to set up a confirmation modal for bulk item deletion. It involves defining modal variables, rendering the modal view, and adding it to the modal collection. It also shows how to integrate with the CP/Table Service for selecting items and adding necessary JavaScript for the confirmation behavior.
```APIDOC
## Bulk item deletion
This example demonstrates how to set up a confirmation modal for bulk item deletion.
### Setup
```php
$modal_vars = array(
'name' => 'modal-confirm-remove',
'form_url' => ee('CP/URL')->make('addons/myaddon/remove')
);
$modal_html = ee('View')->make('ee:_shared/modal_confirm_remove')->render($modal_vars);
ee('CP/Modal')->addModal('remove', $modal_html);
```
### Table Column Setup
To enable item selection, add a checkbox column to your table listing.
```php
$columns[] = array(
'name' => 'content_ids[]',
'value' => $content->getId(),
'data' => array(
'confirm' => lang('content') . ': ' . htmlentities($content->title, ENT_QUOTES, 'UTF-8') . ''
)
);
```
### JavaScript Inclusion
Include the necessary JavaScript for the confirmation functionality.
```php
ee()->cp->add_js_script(array(
'file' => array('cp/confirm_remove'),
));
```
### Bulk Action Controls
Embed the bulk action bar with options to trigger the modal.
```php
embed('ee:_shared/form/bulk-action-bar', [
'options' => [
[
'value' => "",
'text' => '-- ' . lang('with_selected') . ' --'
],
[
'value' => "remove",
'text' => lang('delete'),
'attrs' => ' data-confirm-trigger="selected" rel="modal-confirm-remove"'
]
],
'modal' => true
]); ?>
```
```
--------------------------------
### cURL Request Example
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/actions.md
Example of how to send a POST request with an ID to an ExpressionEngine action endpoint using cURL. This request will be subject to CSRF protection by default.
```bash
curl --location --request POST 'https://anamzingwebsite.test/?ACT=41' --form 'id="1"'
```
--------------------------------
### Generate Add-on with Options
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/make-addon.md
This command generates a new add-on using command-line arguments for the add-on name, version, description, author, and author URL. It's a faster way to create an add-on if you have all the details ready.
```bash
php ../../system/ee/eecli.php make:addon "My Example Addon" -v 0.1.0 -d "Some good description" -a "ExpressionEngine" -u https://expressionengine.com
```
--------------------------------
### Get Addon Information
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/services/addon.md
Retrieve an addon object by its short name and access its properties. Use this to get read-only data from an addon's `addon.setup.php` file.
```php
echo ee('Addon')->get('hello_world')->get('description');
```
--------------------------------
### core_boot()
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/development/extension-hooks/global/core.md
This hook runs tasks on every ExpressionEngine request. It's important to be mindful of performance and resource usage when implementing code for this hook. You can check the `REQ` constant to conditionally execute code based on the request type (PAGE, CP, or ACTION).
```APIDOC
## core_boot()
### Description
Runs tasks on every ExpressionEngine request.
### How it's called
```php
ee()->extensions->call('core_boot');
if (ee()->extensions->end_script === TRUE) return;
```
### Parameters
* Returns: `Void`
### Notes
This hook fires on every ExpressionEngine request. Be mindful of the speed and resource usage of your code. The `REQ` constant can be checked to determine the type of request: `PAGE` (front-end), `CP` (control panel), or `ACTION` (module action requests).
```
--------------------------------
### List Add-ons with Updates Available
Source: https://github.com/expressionengine/expressionengine-user-guide/blob/7.dev/docs/cli/built-in-commands/addons.md
Identify add-ons for which updates are available.
```bash
php eecli.php addons:list a
```
```bash
php eecli.php addons:list update-available
```