# Welcome

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.&#x20;
{% endhint %}

Welcome to the new Developer Guide for e107. <br>

The Developer Guide is still under construction but more and more information is added over time. <br>

You can use the menu on the left to navigate to the underlying pages.&#x20;


# Hello world example

To create a simple test script, create a new file called `helloworld.php` in your root folder with the following PHP code:&#x20;

```php
<?php

require_once("class2.php"); // Load e107's main classes and functionalities
require_once(HEADERF); // Load and output the theme's HTML for the $HEADER.

// Option 1:
echo "Hello World";

// Option 2:
$ns = e107::getRender(); // Load rendering object. 
$ns->tablerender("My Caption", "Hello World");  // Render Caption and Text according to Theme style. 

require_once(FOOTERF); // Load and output the theme's HTML for the $FOOTER. 
exit; 
```

Then point your browser to `www.yoursite.com/helloworld.php`and you're ready!


# Folder structure

&#x20;The table below provides an overview of the default folder structure of an e107 installation:

| Folder          | Can be modified         | Description                                                                                                                                           |
| --------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| e107\_admin     | No                      | Contains main files used for the admin area.                                                                                                          |
| e107\_core      | No                      | <p>Contains core assets. <br><em>You should <strong>not</strong> make changes within this folder.</em></p>                                            |
| e107\_handlers  | No                      | <p>Contains core functions and classes. <br><em>You should <strong>not</strong> make changes within this folder.</em></p>                             |
| e107\_images    | Not usually             | <p>Contains core images. <br><em>You should <strong>not</strong></em> <em><strong>normally</strong> need to make changes within this folder.</em></p> |
| e107\_languages | Not the English folder. | <p>Contains core language files.</p><p><em>Themes and plugins have their own language folder</em></p>                                                 |
| e107\_media     | Not usually             | Contains Media such as downloadable images or files which are specific to your installation.                                                          |
| e107\_plugins   | Yes                     | <p>Contains all plugins, installed and uninstalled. <br><em>You may manually add plugins to this folder if need be.</em></p>                          |
| e107\_system    | Not usually             | Contains **private** files such as logs, plugin and theme downloads which are specific to your installation.                                          |
| e107\_theme     | Yes                     | <p>Contains all themes, installed and uninstalled. <br><em>You may manually add themes to this folder if need be.</em></p>                            |
| e107\_web       | No                      | Contains core *js* and *css* packages.                                                                                                                |


# Database structure

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

### Best practices

* **Do not modify the core database structure**

:thumbsup: Use your own tables (for example by [creating a plugin](/plugin-development/introduction)) if you want to work with additional data in the database. &#x20;

* **Do not (ab)use database tables and fields for other purposes**&#x20;

:thumbsup: Stick to purposes [defined in the database tables](/getting-started/database-structure#database-tables-overview) overview, or create your own database tables

### Database prefix

The default database table prefix is `e107_` and can be customized by the user during the installation of e107. The prefix that is used on an installation can always be found in the `e107_config.php` file.&#x20;

There are several ways the database prefix is used:

1. **Recommended:** It is strongly recommend to make use of the [database methods](/classes-and-methods/database#database-methods). Using these methods, the database table prefix is processed automatically. <br>
2. By using the `#` sign, one can automatically refer to the database prefix. This is generally used when using the[ e107::getDB()->gen()](/classes-and-methods/database#gen) method, to manually construct an SQL query. <br>
3. In rare cases, you may reference the `MPREFIX` constant. Its use is deprecated and **not** encouraged.&#x20;

## Database tables overview&#x20;

{% hint style="info" %}
TODO: Finish table below.&#x20;
{% endhint %}

The following table provides an overview of all database tables in a clean e107 installation, with their respective purposes.&#x20;

| Table name         | Description                                                                                                                                                                    |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| admin\_log         |                                                                                                                                                                                |
| audit\_log         |                                                                                                                                                                                |
| banlist            |                                                                                                                                                                                |
| comments           |                                                                                                                                                                                |
| core               |                                                                                                                                                                                |
| core\_media        |                                                                                                                                                                                |
| core\_media\_cat   |                                                                                                                                                                                |
| cron               |                                                                                                                                                                                |
| dblog              |                                                                                                                                                                                |
| generic            | <p>Table for generic purposes. Generally used to store temporary date. Currently also used by welcome message. <br><em>Developers are discouraged to use this table!</em> </p> |
| links              |                                                                                                                                                                                |
| mail\_recipients   |                                                                                                                                                                                |
| mail\_content      |                                                                                                                                                                                |
| menus              |                                                                                                                                                                                |
| news               |                                                                                                                                                                                |
| news\_category     |                                                                                                                                                                                |
| online             |                                                                                                                                                                                |
| page               |                                                                                                                                                                                |
| page\_chapters     |                                                                                                                                                                                |
| plugin             |                                                                                                                                                                                |
| rate               |                                                                                                                                                                                |
| submitnews         |                                                                                                                                                                                |
| tmp                |                                                                                                                                                                                |
| upload             |                                                                                                                                                                                |
| user               |                                                                                                                                                                                |
| userclass\_classes |                                                                                                                                                                                |
| user\_extended     |                                                                                                                                                                                |
|                    |                                                                                                                                                                                |


# Debugging & problem solving

## Introduction

Your code should not produce any PHP warnings or notices during normal usage. This primarily implies that all variables must be defined before being used. It also implies that a corrupted installation may produce errors, although as far as practicable the code should accommodate this.&#x20;

{% hint style="warning" %}
By default, all PHP errors, warnings and notices are suppressed and not visible to the public. You can use debugging to show them.&#x20;
{% endhint %}

{% hint style="info" %}
A blank page or a page that has not been fully loaded, usually indicates a PHP fatal error. Server logs (such as Apache Error Logs) often also provide useful information.&#x20;
{% endhint %}

## Browser addon

We recommend this collection of :point\_right: [Firefox Addons](https://addons.mozilla.org/en-US/firefox/collections/camer0n/e107developer/). The most important being the `e107 Debugger`. If you don't wish to use the debugger, you can still activate various [debugging modes](/getting-started/debugging-and-problem-solving#debug-modes) manually, by changing the query string of the URL and adding the debug mode. For example: directly after `.php` add `?[debug=xxxx]`

*Example:* `yourwebsite.com/news.php?[debug=basic!]`

## Debug modes

| Query                | Description                                 |
| -------------------- | ------------------------------------------- |
| \[debug=basic!]      | Display basic error information             |
| \[debug=traffic!]    | Display traffic information                 |
| \[debug=showsql!]    | Display basic SQL queries                   |
| \[debug=time!]       | Display load/processing times               |
| \[debug=notice!]     | Display PHP Notices                         |
| \[debug=warn!]       | Display PHP Warnings                        |
| \[debug=backtrace!]  | Display PHP Backtraces                      |
| \[debug=deprecated!] | Display deprecated method or function calls |
| \[debug=inc!]        | Display included files                      |
| \[debug=paths!]      | Display paths and variables                 |
| \[debug=bbsc!]       | Display BBCodes and Shortcodes              |
| \[debug=sc!]         | Display Shortcode placement                 |
| \[debug=sql!]        | Display detailed SQL analysis               |
| \[debug=everything!] | Display all debugging details               |
| \[debug=off!]        | Disable debugging                           |

{% hint style="info" %}
As of e107 v2.3.1 - the `+` sign has been changed to an exclamation mark `!`. \
For example: `[debug=basic!]` instead of `[debug=basic+]`
{% endhint %}


# Introduction

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Overview

The table below provides a quick overview of all classes that are used in e107 and are commonly used by developers.&#x20;

| Class                                           | Description                                        |
| ----------------------------------------------- | -------------------------------------------------- |
| [Database](/classes-and-methods/database)       | All methods related to interaction with a database |
| [Forms](/classes-and-methods/forms)             |                                                    |
| [Parser](/classes-and-methods/parser)           | .                                                  |
| [Render](/classes-and-methods/render)           |                                                    |
| [Preferences](/classes-and-methods/preferences) |                                                    |
| [Javascript](/classes-and-methods/javascript)   |                                                    |
| [CSS](/classes-and-methods/css)                 |                                                    |
| [User Data](/classes-and-methods/user-data)     |                                                    |
| [Meta](/classes-and-methods/meta)               |                                                    |
| [Events](/classes-and-methods/events)           |                                                    |
| [Alerts](/classes-and-methods/alerts)           |                                                    |
| [Logging](/classes-and-methods/logging)         |                                                    |
| [Redirection](/classes-and-methods/redirection) |                                                    |
| [URLs](/classes-and-methods/urls)               |                                                    |
| [Cache](/classes-and-methods/cache)             |                                                    |

##


# Alerts

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the alerts class object.&#x20;

```php
$mes = e107::getMessage();
```

## Alerts methods

### addSuccess()

```php
$mes = e107::getMessage();
$mes->addSuccess('You did it!');
```

### addError()

```php
$mes = e107::getMessage();
$mes->addError('There was a problem!');
```

### addWarning()

```php
$mes = e107::getMessage();
$mes->addWarning('You do not have access to this area!');
```

### addInfo()

```php
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
```

### addDebug()

{% hint style="info" %}
*Messages assigned here will only be displayed when* [*debug mode*](/getting-started/debugging-and-problem-solving) *is active.*
{% endhint %}

```php
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
```

### render()

None of the above methods will output anything, until you use this method to render them.

```php
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
echo $mes->render();
```


# Cache

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

```php
$cache = e107::getCache();
```

## Cache methods

### retrieve()

### retrieve\_sys()

### set()

### clear()

### clear\_sys()

## Cache types

{% hint style="info" %}
Work in progress
{% endhint %}

| Type                                                                              | content?                       |
| --------------------------------------------------------------------------------- | ------------------------------ |
| online\_menu\_totals                                                              |                                |
| wmessage                                                                          |                                |
| news                                                                              |                                |
| 'newsarchive'                                                                     | \_caption,\_title,\_diz,\_rows |
| "nq\_othernews"                                                                   |                                |
| news\_php\_extend\_'.$id.'\_'                                                     |                                |
| 'nq\_news\_latest\_menu\_'.md5(serialize($parm).USERCLASS\_LIST.e\_LANGUAGE);     |                                |
| 'nq\_news\_categories\_menu\_'.md5(serialize($parm).USERCLASS\_LIST.e\_LANGUAGE); |                                |
| 'nq\_news\_months\_menu\_'.md5(serialize($parm).USERCLASS\_LIST.e\_LANGUAGE);     |                                |
| 'news.php\_default\_'                                                             |                                |
| 'news.php\_'.e\_QUERY                                                             |                                |
| comment.php?{$table}.{$id}                                                        |                                |
| nq\_chatbox                                                                       |                                |
| nomd5\_linkwords                                                                  |                                |
| nomd5\_user\_ranks                                                                |                                |
| 'menus\_'.USERCLASS\_LIST.'\_'.md5(e\_LANGUAGE.$menu\_layout\_field)              |                                |


# CSS

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

...

## Basic CSS methods

Including css in your plugin or theme may be achieved by using the following function:

```php
e107::css($type, $value);
```

| Type   | Value                               | Description                                                  |
| ------ | ----------------------------------- | ------------------------------------------------------------ |
| theme  | path relative to the theme's folder | Include a theme css file in the header of the site           |
| url    | full url to css file                | Include a remote css file in the header of the site          |
| inline | css code                            | Include raw css code in the header of every page of the site |

## Examples

{% hint style="info" %}
TODO: add examples
{% endhint %}


# Database

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the database class object

```php
$sql = e107::getDb();
```

## Basic database methods&#x20;

### select()

Selecting data from a database table

```php
$sql->select($table, $fields = '*', $arg = '', $noWhere = false, $debug = false, $log_type = '', $log_remark = '')
```

| Parameter   | Type          | Description                                                               | Mandatory? |
| ----------- | ------------- | ------------------------------------------------------------------------- | ---------- |
| **table**   | string        | Name of the database table                                                | **Yes**    |
| fields      | string        | Comma separated list of fields or "`*`" or a single field name (get one); |            |
| arg         | string\|array | ....                                                                      |            |
| noWhere     | boolean       |                                                                           |            |
| debug       | boolean       |                                                                           |            |
| log type    |               |                                                                           |            |
| log\_remark |               |                                                                           |            |

#### Example #1: Simple select&#x20;

```php
$sql->select('tablename', 'field1, field2', 'field_id = 1');
```

#### Example #2: Using arguments&#x20;

```php
$sql->select("comments", "*", "comment_item_id = '$id' AND comment_type = '1' ORDER BY comment_datestamp");
```

#### Example #3: Using arguments with noWhere option

```php
$sql->select("chatbox", "*", "ORDER BY cb_datestamp DESC LIMIT $from, ".$view, true);
```

#### Example #4: BIND support

```php
$sql->select('user', 'user_id, user_name', 'user_id=:id OR user_name=:name ORDER BY user_name', array('id' => 999, 'name'=>'e107'))
```

### fetch()

Selecting, looping through and displaying selected data with the fetch() method:

```php
$sql->select('tablename', 'field1, field2', 'field_id = 1');

while($row = $sql->fetch())
{
    echo $row['field1'];
}
```

### insert()

Inserting data into a database table:

```php
$insert = array(
   'data'  => array('field1' => 'value1', 'field2' => 'value2'),
   'WHERE' => 'field_id = 1'
);

$sql->insert('tablename', $insert);
```

### update()

Updating information in a database:

```php
$update = array(
   'data'  => array('field1' => 'value1', 'field2' => 'value2'),
   'WHERE' => 'id = 1'
);

$sql->update('tablename', $update);
```

### retrieve()

Combined [select()](/classes-and-methods/database#select) and [fetch()](/classes-and-methods/database#fetch) method.

```php
$sql->retrieve($table = null, $fields = null, $where = null, $multi = false, $indexField = null, $debug = false)
```

| Parameter  | Type    | Description                                                                                                                                                                                                                              |
| ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| table      | string  | <p>Name of the database table to retrieve data from. </p><p>If empty, enters fetch only mode</p>                                                                                                                                         |
| fields     | string  | <p>Comma separated list of fields or "<code>\*</code>" or a single field name (get one); <br><br>If <code>$fields</code> is of type boolean and <code>$where</code> is not found, <code>$fields</code> overrides <code>$multi</code></p> |
| where      | string  | WHERE/ORDER/LIMIT etc. clause.                                                                                                                                                                                                           |
| multi      | string  | <p>If set to true, fetch all (multi mode)</p><p><em>Default: false</em></p>                                                                                                                                                              |
| indexField | boolean | <p>Field name to be used for indexing when in multi mode</p><p><em>Default:  null</em></p>                                                                                                                                               |
| debug      | boolean | <p>....</p><p><em>Default: false</em></p>                                                                                                                                                                                                |

#### Example #1: Get a single value

```php
$string = $sql->retrieve('user', 'user_email', 'user_id = 1');
```

#### Example #2: Get multiple table-row values

```php
if($allRows = $sql->retrieve('user', 'user_name, user_email', '', true))
{
	foreach($allRows as $row)
	{
		echo $row["user_name"]." - ".$row["user_email"]."<br/>";  
	}
}
```

#### Example #3: Fetch all, don't append WHERE to the query, index by user\_id, noWhere auto detected (string starts with upper case ORDER)

```php
$array = $sql->retrieve('user', 'user_id, user_email, user_name', 'ORDER BY user_email LIMIT 0,20', true, 'user_id');
```

#### Example #4: Same as above but retrieve() is only used to fetch, not useable for single return value&#x20;

```php
if($sql->select('user', 'user_id, user_email, user_name', 'ORDER BY user_email LIMIT 0,20', true))
{
     $array = $sql->retrieve(null, null, null,  true, 'user_id');
}
```

#### Example #5: Using whole query example, in this case default mode is 'one'&#x20;

```php
$array = $sql->retrieve('
    SELECT p., u.user_email, u.user_name 
    FROM `#user` AS u
    LEFT JOIN `#myplug_table` AS p 
    ON p.myplug_table = u.user_id
    ORDER BY u.user_email LIMIT 0,20
');
```

#### Example #6: Using whole query example, multi mode - $fields argument mapped to $multi&#x20;

```php
$array = $sql->retrieve('SELECT u.user_email, u.user_name FROM #user AS U ORDER BY user_email LIMIT 0,20', true);
```

### delete()

Delete a record from a database table.

```php
$sql->delete("user", "user_id = 2");
```

### gen()

Generic query function to use various SQL commands.&#x20;

#### *Example: perform a JOIN with gen():*

```php
$sql->gen("SELECT f.*,u.user_name FROM #faqs AS f LEFT JOIN #users as u ON f.faq_author = u.user_id ");
```

## &#x20;Advanced database methods

### connect()

```php
$sql->connect($mySQLserver, $mySQLuser, $mySQLpassword, $newLink = false)
```

| Parameter     | Type    | Description                                                                   |
| ------------- | ------- | ----------------------------------------------------------------------------- |
| mySQLserver   | string  | IP or hostname of the SQL server                                              |
| mySQLuser     | string  | SQL username                                                                  |
| mySQLpassword | string  | SQL password                                                                  |
| newLink       | boolean | <p>force a new link connection if set to true <br><em>Default: false</em></p> |

### count()

### database()

```php
$sql->database($database, $prefix = MPREFIX, $multiple=false)
```

| Parameter | Type    | Description                                                                                                                |
| --------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| database  | string  | Database name                                                                                                              |
| prefix    | string  | Prefix of the database tables (e.g. "e107\_"). Defaults to [MPREFIX](/getting-started/database-structure#database-prefix). |
| multiple  | boolean | Set to true to maintain connection to a secondary database                                                                 |
| newLink   | boolean | <p>force a new link connection if set to true <br><em>Default: false</em></p>                                              |

### getLastErrorNumber()

### getLastErrorText()


# Date

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

```php
$gen = e107::getDate();
```

## Date methods

### computeLapse()

Calculate difference between two dates for display in terms of years/months/weeks....

```php
$gen->computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long') 
```

| Parameter       | Type    | Description                                                                                                                          | Mandatory? |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------- |
| **older\_date** | integer | UNIX timestamp                                                                                                                       | **Yes**    |
| newer\_date     | integer | <p>UNIX timestamp</p><p><em>Default:</em> current time</p>                                                                           | No         |
| mode            | boolean | <p>if <em>true</em> return value is an array. Otherwise return value is a string</p><p><em>Default: false</em></p>                   | No         |
| show\_secs      | boolean | *Default: true*                                                                                                                      | No         |
| format          | string  | <p>Format of the human readable date. Options:</p><ul><li>long</li><li>short (omits the year)</li></ul><p><em>Default: long</em></p> | No         |

### convert\_date()

Convert datestamp to human readable date. System time offset is considered.

```php
$gen->convert_date($datestamp, $mask = '')
```

| Parameter | Type    | Description                                                                                                                                                                                                                                                                                                                                    | Mandatory? |
| --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| datestamp | integer | UNIX timestamp                                                                                                                                                                                                                                                                                                                                 | **Yes**    |
| mask      | string  | <p>Format of the human readable date. Options:</p><ul><li>long</li><li>short</li><li>forum</li><li>relative</li><li>(any <span data-gb-custom-inline data-tag="emoji" data-code="1f449">👉</span><a href="https://www.php.net/manual/en/function.strftime.php"><code>strftime()</code></a>valid string)</li></ul><p><em>Default: long</em></p> | No         |

{% hint style="info" %}
The configuration of the *mask* formats are specified in :point\_right: Admin Area > Preferences > [Date Display options](https://userguide.e107.org/administration/settings/preferences#date-display-options).&#x20;
{% endhint %}

### terms()

Return an array of language terms representing months

```php
$gen->terms($type='month')
```

| Parameter | Type   | Description                                                                                                                                                                                                                  | Mandatory? |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| type      | string | <p>Options:</p><ul><li>month <em>(August)</em></li><li>month-short <em>(Aug)</em></li><li>day <em>(Tuesday)</em></li><li>day-short <em>(Tue)</em></li><li>day-shortest <em>(Tu)</em></li></ul><p><em>Default:</em> month</p> | **Yes**    |


# Events

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.&#x20;
{% endhint %}

## Introduction

Plugin developers can hook into various e107 core events and [trigger functions of their own](/classes-and-methods/events#trigger). Typically, an [e\_event.php](/plugin-development/extending-core-functionality-addons#e_event-php) file is used to store this information since it is loaded with every page.

{% hint style="info" %}
From e107 version 2.1.2 onwards you can use [e\_event.php](/plugin-development/extending-core-functionality-addons#e_event-php) addon to catch the events instead of using [e\_module.php](/plugin-development/extending-core-functionality-addons#e_module-php)
{% endhint %}

## &#x20;Events methods

### register()

| Parameter    | Description                                                                                                                        | Mandatory? |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| **name**     | The event you wish to hook into. ([see tables below](/classes-and-methods/events#event-triggers))                                  | **Yes**    |
| **function** | Your function or class/method to trigger when this event occurs. string for function, or for classes use an array (class, method). | **Yes**    |
| include      | include (optional) path: a file to include if required.                                                                            | No         |

```php
e107::getEvent()->register(name, function, include);
```

#### **Example 1**: trigger `myFunction()` on user login.

```php
e107::getEvent()->register('login', 'myFunction'); 

function myFunction($data)
{
   // do something    
}
```

#### **Example 2**: trigger `myFunction()` on user login. Function in external file.

```php
e107::getEvent()->register('login', 'myFunction',  e_PLUGIN."myplugin/myFunctions.php");
```

#### **Example 3**: trigger a class and method on user login.

```php
e107::getEvent()->register('login', array('myClass', 'myMethod'),  e_PLUGIN."myplugin/myClass.php");
```

### trigger()

Triggers an event. This can be used by plugin authors to create their own plugin events that other developers can hook into.&#x20;

```php
e107::getEvent()->trigger($eventname, $data = '');

// Example for plugin authors to create their own plugin event:
e107::getEvent()->trigger("plugindir_customevent", $data = ''); // plugindir is the name of the plugin folder
```

| Parameter     | Description                                                                                                                                                | Mandatory? |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| **eventname** | <p>The name of the event you wish to trigger (new event name). <br><br><em><strong>Format:</strong></em> plugindir\_eventname<br>(see example above). </p> | **Yes**    |
| data          | The data that you wish to send alongside the event                                                                                                         | No         |

## Core Event triggers

### User Event Triggers

#### Basic user functions&#x20;

| Trigger Name            | Description                                                                    | Data                                           |
| ----------------------- | ------------------------------------------------------------------------------ | ---------------------------------------------- |
| login                   | User login/signin                                                              | Array of user data                             |
| logout                  | User logout/signout                                                            | Notice event                                   |
| user\_file\_upload      | User uploads a file                                                            | Array of file information                      |
| user\_signup\_submitted | User submits signup form                                                       | Array of user data                             |
| user\_signup\_activated | User activates newly created account. (email link)                             | Array of user data                             |
| user\_xup\_login        | User signs in via a social media account. eg. Facebook, Twitter etc.           | Array of user data                             |
| user\_xup\_signup       | User creates an account using their social media login. Facebook, Twitter etc. | Array of user data                             |
| user\_profile\_display  | User has viewed a profile                                                      | Array of data                                  |
| user\_profile\_edit     | User has edited their profile                                                  | Array of data of user who changed the settings |
| user\_comment\_posted   | User has posted a new comment                                                  | Array of data                                  |
| preuserset              | Before usersettings are updated                                                | Array of new user settings ($\_POST)           |
| postuserset             | After usersettings are updated                                                 | Array of new user settings ($\_POST)           |
| userdatachanged         | After usersettings are updated (same time and data as user\_profile\_edit)     | Array of data of user who changed the settings |

#### **Custom page**

| Trigger function         | Description                   | Data          |
| ------------------------ | ----------------------------- | ------------- |
| user\_page\_item\_viewed | User has viewed a custom page | Array of data |

#### **News**

| Trigger Name             | Description                | Data          |
| ------------------------ | -------------------------- | ------------- |
| user\_news\_item\_viewed | User viewed a news item    | Array of data |
| user\_news\_submit       | User submitted a news item | Array of data |

#### **Private Messenger**

| Trigger name   | Description                     | Data          |
| -------------- | ------------------------------- | ------------- |
| user\_pm\_sent | User has sent a private message | Array of data |
| user\_pm\_read | User has read a private message | Array of data |

#### **Forum**

| Trigger Name                              | Description                                     | Data          |
| ----------------------------------------- | ----------------------------------------------- | ------------- |
| user\_forum\_topic\_created               | User creates a forum topic                      | Array of data |
| user\_forum\_topic\_created\_probationary | New user creates a forum topic                  | Array of data |
| user\_forum\_topic\_updated               | User updates a forum topic                      | Array of data |
| user\_forum\_topic\_deleted               | User deletes a forum topic                      | Array of data |
| user\_forum\_topic\_moved                 | User has moved forum topic to a different forum | Array of data |
| user\_forum\_topic\_split                 | User has split the forum topic                  | Array of data |
| user\_forum\_post\_created                | User creates a forum post/reply                 | Array of data |
| user\_forum\_post\_updated                | User updates a forum post/reply                 | Array of data |
| user\_forum\_post\_deleted                | User deletes a forum post/reply                 | Array of data |
| user\_forum\_post\_report                 | User has reported a forum post/reply            | Array of data |

#### **Chatbox**

| Trigger function             | Description                       | Data                           |
| ---------------------------- | --------------------------------- | ------------------------------ |
| user\_chatbox\_post\_created | User has posted a chatbox message | Array of data (ip and message) |

### Admin Event Triggers

#### **Admin changes their password**

| Trigger Name            | Description                  | Data                                          |
| ----------------------- | ---------------------------- | --------------------------------------------- |
| admin\_password\_update | Admin updates their password | Array containing user\_id and time of change. |

#### **Comments Manager**

| Trigger Name           | Description             | Data                  |
| ---------------------- | ----------------------- | --------------------- |
| admin\_comment\_update | Admin updates a comment | Array of comment data |
| admin\_comment\_delete | Admin deletes a comment | Array of comment data |

#### **Downloads**

| Trigger Name            | Description                   | Data                   |
| ----------------------- | ----------------------------- | ---------------------- |
| admin\_download\_create | Admin creates a download item | Array of download data |
| admin\_download\_update | Admin updates a download item | Array of download data |
| admin\_download\_delete | Admin deletes a download item | Array of download data |

#### **News**

| Trigger Name                  | Description                   | Data               |
| ----------------------------- | ----------------------------- | ------------------ |
| admin\_news\_create           | Admin creates a news item     | Array of news data |
| admin\_news\_update           | Admin updates a news item     | Array of news data |
| admin\_news\_delete           | Admin deletes a news item     | Array of news data |
| admin\_news\_category\_create | Admin creates a news category | Array of news data |
| admin\_news\_category\_update | Admin updates a news category | Array of news data |
| admin\_news\_category\_delete | Admin deletes a news category | Array of news data |

#### **Pages**

| Trigger Name        | Description                    | Data                             |
| ------------------- | ------------------------------ | -------------------------------- |
| admin\_page\_create | Admin creates a page/menu item | Array of page data               |
| admin\_page\_update | Admin updates a page/menu item | Array of page data (new and old) |
| admin\_page\_delete | Admin deletes a page/menu item | Array of page data               |

#### **Users**

| Trigger Name          | Description                        | Data                             |
| --------------------- | ---------------------------------- | -------------------------------- |
| admin\_user\_create   | Admin creates a new user           | Array of user data               |
| admin\_user\_update   | Admin modifies user data           | Array of user data (new and old) |
| admin\_user\_delete   | Admin deletes a user               | Array of user data               |
| admin\_user\_activate | Admin activates an unverified user | Array of user data               |
| admin\_user\_loginas  | Admin logs in as another user      | Array of user data               |
| admin\_user\_logoutas | Admin logs out as another user     | Array of user data               |


# Forms

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the form class object

```php
$frm = e107::getForm();
```

## Forms methods

### open()

Returns a form opening tag.

```php
$frm->open('myform'); 
```

```php
$frm->open('myform', 'get', 'myscript.php', array('autocomplete' => 'on', 'class' => 'formclass'));
```

| Parameter | Type   | Description                                                                                                                                           | Mandatory                     |    |
| --------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -- |
| **name**  | string | Name of the form                                                                                                                                      | **Yes**                       |    |
| mode      | string | <p>post                                                                                                                                               | get <br>'post' by default</p> | No |
| target    | string | <p>The request URL <br><code>e\_REQUEST\_URI</code> by default</p>                                                                                    | No                            |    |
| options   | array  | <p>Specify options such as class or autocomplete</p><p></p><ul><li>autocomplete - on/off (boolean)</li><li>class - (any string)</li><li>...</li></ul> | No                            |    |

### close()

Returns a form closing tag

```php
$frm->close();
```

### text()

Returns a text field form element

```php
$frm->text('my-field', 'current_value', 100, array('size' => 'large')); // returns <input class="tbox input-large" id="my-field" maxlength="100" name="my-field" type="text" value="current_value"></input>
```

| Parameter | Type    | Description                                                                                                                                                                                                   | Mandatory |
| --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| name      | string  | Name of the text field                                                                                                                                                                                        |           |
| value     | string  | Value of the text field                                                                                                                                                                                       |           |
| maxlength | integer | Specifies the maxlength element of the text field                                                                                                                                                             |           |
| options   | array   | <p>Specify options such as class, size or selectize<br></p><ul><li>class: (any string)</li><li>size: mini, small, medium, large, xlarge, xxlarge</li><li>selectize: array with selectize.js options</li></ul> |           |

### textarea()

```php
$frm->textarea($name, $value, $rows, $cols, $options, $counter);
```

### bbarea()

```php
$frm->bbarea($name, $value, $template, $mediaCat, $size, $options);
```

| Parameter | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Mandatory |
| --------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| **name**  | string | Name of the field                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | **Yes**   |
| **value** | string | Contents of the field                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | **Yes**   |
| template  | string | <p>A string defining the button template to use with bbarea. Included in the core are the following: news, submitnews, extended, admin, mailout, page, comment, signature<br><br>But you can also use the name of the plugin (e.g. forum) if the plugin provides a bbcode\_template.php</p>                                                                                                                                                                                                                                                                                                    | No        |
| mediaCat  | string | <p>Name of the media catalog to use <br>(default: \_common)</p><p><br><em>Is only used by TinyMCE plugin (if installed and used)</em></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                      | No        |
| size      | string | <p>Size of the bbarea/editor.<br>Use one of the following values: tiny, small, medium, large <br>(default: large)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | No        |
| options   | array  | <p>Array with options to use with the editor:<br>id: string - In case the bbarea/editor id should be different to the name<br>class: string - the css classes to use<br>counter: boolean - Show a character counter<br>wysiwyg: boolean/string -</p><ul><li>False in case you want disable the wysiwyg editor for this field and use the default bbcode editor.</li><li>True to enable the current installed (and enabled) wysiwyg editor</li><li>Name of the editor (e.g. tinymce4 or simplemde) to use, in case wysiwyg is generally enabled and the supplied editor is installed.</li></ul> | No        |

### select()

```php
$frm->select($name,$option_array,$selected,$options,$defaultBlank);
```

### checkbox()

```php
$frm->checkbox($name,$value,$checked,$options);
```

### hidden()

```php
$frm->hidden($name,$value,$options);
```

### button()

```php
$frm->button($name,$value,$action,$label,$options);
```

### carousel()&#x20;

Render a Bootstrap carousel

```php
$frm->carousel($name, $array, $options);
```

```php
$array = array(
      'slide1' => array('caption' => 'Slide 1', 'text' => 'first slide content' ),
      'slide2' => array('caption' => 'Slide 2', 'text' => 'second slide content' ),
      'slide3' => array('caption' => 'Slide 3', 'text' => 'third slide content' )
  );

echo $frm->carousel('my-carousel', $array);
```

### tabs()&#x20;

Render Bootstrap tabs

```php
$frm->tabs($array,$options);
```

```php
$array = array(
   'home'  => array('caption' => 'Home', 'text' => 'some tab content' ),
   'other' => array('caption' => 'Other', 'text' => 'second tab content' )
);

echo $frm->tabs($array);

echo $frm->tabs($array, array('active' => 'other')); // make 'other' the initial active tab. 
```

### datepicker()

Date field with popup calendar. Returns UNIX timestamp or string value on submit.

```php
$frm->datepicker($name, $datestamp = false, $options = null)
```

| Parameter | Type             | Description                                                                                                                                                                                                                                                                                                     | Mandatory? |
| --------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| **name**  | string           | The name of the field                                                                                                                                                                                                                                                                                           | **Yes**    |
| datestamp | integer\|boolean | <p>UNIX timestamp. Set the default value of the field.</p><p><em>Default:</em> false</p>                                                                                                                                                                                                                        | No         |
| options   | array\|string    | <p>Available options (see <a href="/pages/-M8AHnecKxhYmHJUvikL#examples">examples</a> below):</p><ul><li>mode - 'date' or 'datetime'</li><li>format - </li><li>timezone</li><li>size</li><li>required (true/false)</li><li>firstDay</li><li>disabled</li><li>placeholder</li></ul><p><em>Default: null</em></p> | No         |

{% hint style="info" %}
**TODO:** Clarify possible options and add more examples
{% endhint %}

#### *Examples:*

```php
$frm->datepicker('my_field',time(),'mode=date');
$frm->datepicker('my_field',time(),'mode=datetime&inline=1');
$frm->datepicker('my_field',time(),'mode=date&format=yyyy-mm-dd');
$frm->datepicker('my_field',time(),'mode=datetime&format=MM, dd, yyyy hh:ii');
$frm->datepicker('my_field',time(),'mode=datetime&return=string');
```


# Javascript

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

....

## Basic Javascript methods

Including Javascript in your plugin or theme may be achieved by using the following function:

```php
e107::js($type, $data, $parm = null, $zone = null, $pre = '', $post = '')
```

| Parameter | Value                             | Description                                          | Mandatory? |
| --------- | --------------------------------- | ---------------------------------------------------- | ---------- |
| type      | See [type & data](#type-and-data) |                                                      | **Yes**    |
| data      | See [type & data](#type-and-data) |                                                      | **Yes**    |
| parm      | jquery \| array                   | Specifies dependencies or other parameters           | No         |
| zone      |                                   | Specifies the zone in which the javascript is loaded | No         |
| pre       |                                   |                                                      | No         |
| post      |                                   |                                                      | No         |

### type & data

| Type                                                 | Data                                                    | Description                                                    |
| ---------------------------------------------------- | ------------------------------------------------------- | -------------------------------------------------------------- |
| core                                                 | path relative to the core folder                        | Include a core js file                                         |
| url                                                  | full URL to javascript file                             | Include a remote js file                                       |
| inline                                               | javascript code                                         | Include raw javascript code                                    |
| theme                                                | path to js file, relative to the current theme's folder | Include a theme js file                                        |
| (any plugin folder name)                             | path to js file, relative to the plugin's folder        | Include a plugin js file                                       |
| [settings](/classes-and-methods/javascript#settings) | array                                                   | Adds settings to e107's global storage of JavaScript settings. |

### Examples

#### *Example #1*

Load a script in the 'faqs' plugin directory and auto-load jQuery if not already loaded.

```php
e107::js('faqs','js/faqs.js', 'jquery')
```

#### *Example #2*

Load a theme script in the footer

```php
e107::js("theme", "js/scripts.js", 'jquery');  // no 'zone' value, loaded in the footer by default. 
```

#### Example *#3*

Load a theme script in the header

```php
e107::js("theme", "js/scripts.js", 'jquery', 2); // including a 'zone' value loads it in the header 
```

### **settings**

An associative array with configuration options.&#x20;

* The array is merged directly into `e107.settings`.&#x20;
* All plugins should wrap their actual configuration settings in another variable to prevent conflicts in the e107.settings namespace.
* Items added with a string key will replace existing settings with that key; items with numeric array keys will be added to the existing settings array.

{% hint style="info" %}
Remember that loading from URL may take more time than local resources. Use dependency if needed!
{% endhint %}

## JavaScript Behaviors

Behaviors are event-triggered actions that attach to page elements, enhancing default non-JavaScript UI's.&#x20;

Behaviors are registered in the `e107.behaviors` object using the method 'attach' and optionally also 'detach' as follows:

```javascript
var e107 = e107 || {'settings': {}, 'behaviors': {}};

(function ($)
{
  e107.behaviors.myBehavior = {
    attach: function (context, settings)
    {

    },
    detach: function (context, settings, trigger)
    {

    }
  };
})(jQuery);
```

`e107.attachBehaviors` is added to the jQuery ready event and so runs on initial page load. Developers implementing Ajax in their solutions should also call this function after new page content has been loaded, feeding in an element to be processed, in order to attach all behaviors to the new content.

See the `e107_web/js/core/all.jquery.js` file for more information.

## Using jQuery

jQuery is now namespaced to avoid conflicts with other Javascript libraries such as Prototype. All your code that expects to use jQuery as $ should be wrapped in an outer context like so.

```javascript
(function ($) {
  // All your code here.
})(jQuery);
```

If you don't, you may see the following error:`Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function or similar`

### jQuery Once

`e107.behaviors` will often be called multiple times on a page. For example, core/custom plugin performs some Ajax operation, all e107 behaviors will be executed again after page load, in order to attach any relevant JavaScript to the newly loaded elements.&#x20;

This can have the undesired affect of applying JavaScript to elements each time e107 behaviors are executed, resulting in the same code being applied multiple times. To ensure that the JavaScript is applied only once, we can use the `jQuery $.once()` function. This function will ensure that the code inside the function is not executed if it has already been executed for the given element.

Using `jQuery $.once()` (integrated into e107 core), the developer experience of applying these effects is improved. Note that there is also the $.removeOnce() method that will only take effect on elements that have already applied the behaviors.

```javascript
var e107 = e107 || {'settings': {}, 'behaviors': {}};

(function ($)
{

  e107.behaviors.myBehavior = {
    attach: function (context, settings)
    {
      $(context).find(".some-element").once('my-behavior').each(function ()
      {
        // All your code here.
      });
    }
  };

})(jQuery);
```

### Settings passed locally to JavaScript Behaviors

```javascript
e107.behaviors.myBehavior = {
  attach: function(context, settings) {
    $('#example', context).html(settings.myvar);
  }
};
```

### How to override a JavaScript Behavior

If you want to override a bit of core (or third party) e107 JavaScript Behavior, just copy the behavior to your Javascript file (e.g in your plugin or theme), then load it after the original code using "zones".


# Language

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the language class object

```php
$lng = e107::getLanguage()
```

## Language methods

### bcDefs()


# Logging

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## **Introduction**

You can log events to the admin [System Logs](https://userguide.e107.org/administration/tools/system-logs) by using the built in log class.\
\
Use the following to retrieve the alerts class object.&#x20;

```php
$log = e107::getLog();
```

## Logging methods

### add()

| Parameter | Description                                                                                            |
| --------- | ------------------------------------------------------------------------------------------------------ |
| name      | Title or name for the log event.                                                                       |
| details   | Details for the log event - can be either a string of text or an array.                                |
| type      | The type of event. ([see table below](/classes-and-methods/logging#logging-types))                     |
| code      | Custom reference code for your type of event. It should be short, ALL CAPITALS and not contain spaces. |

```php
$log = e107::getLog();
$log->add(name, details, type, code);

//Example: 
$log->add('My Event Name', $myDetailedData, E_LOG_INFORMATIVE, 'MYCODE');
```

## Logging types

| Type                | Description         |
| ------------------- | ------------------- |
| E\_LOG\_INFORMATIVE | Informational event |
| E\_LOG\_NOTICE      | Notice event        |
| E\_LOG\_WARNING     | Warning event       |
| E\_LOG\_FATAL       | Fatal event         |


# Meta

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

Include meta tags in the html header.

```php
e107::meta($name, $content, $extended);
```

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| name      | ...  | ..          |
| content   | ...  | ...         |
| extended  | ...  | ...         |

## Examples

```php
e107::meta('keywords','some words'); 
e107::meta('apple-mobile-web-app-capable','yes'); 
```

{% hint style="info" %}
TODO: add more examples
{% endhint %}


# Parser

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the parser class object.&#x20;

```php
$tp = e107::getParser();
```

## Parser methods

### toHTML()

Parse HTML in various ways. eg. replace constants, convert bbcode etc.

```php
$tp->toHTML($text, $parseBB = false, $modifiers = '', $postID = '', $wrap = false)
```

<table><thead><tr><th width="150">Parameter</th><th width="150">Type</th><th width="297.6130768997373">Description</th><th width="150">Mandatory?</th></tr></thead><tbody><tr><td><strong>text</strong></td><td>string</td><td>text or HTML to be parsed</td><td><strong>Yes</strong></td></tr><tr><td>bparseBB</td><td>boolean</td><td>set to true to parse BBcodes into HTML</td><td>No</td></tr><tr><td>modifiers</td><td>string</td><td>Choose from pre-defined <a href="#parser-modifiers">Parser modifiers</a>. </td><td>No</td></tr><tr><td>postID</td><td></td><td></td><td>No</td></tr><tr><td>wrap</td><td>boolean</td><td><br><em>Default: false</em></td><td>No</td></tr></tbody></table>

#### Example

```php
$tp->toHtml("<strong class="bbcode bold bbcode-b bbcode-b-page">Bold print</strong>", true, 'BODY'); 
```

### toDate()

Convert a UNIX timestamp into a readable format.

```php
$tp->toDate($datestamp = null, $format = 'short')
```

<table><thead><tr><th width="150">Parameter</th><th width="150">Type</th><th width="242.2520274269957">Description</th><th>Mandatory?</th></tr></thead><tbody><tr><td><strong>datestamp</strong></td><td>unix <br>timestamp</td><td></td><td><strong>Yes</strong></td></tr><tr><td>format</td><td>string</td><td>short - Short date format as defined in admin preferences<br><br>long - Long date format as defined in admin preferences<br><br>relative - relative time format. eg. "2 days ago"<br><br><em>Default: short</em></td><td></td></tr></tbody></table>

### toText()

Convert html to plain text.

```php
$tp->toText(string);
```

### createConstants()

Convert `e_xxxxx` paths to their equivalent shortcodes. eg. `e_PLUGIN` becomes `{e_PLUGIN}`

```php
$tp->createConstants(string);
```

### replaceConstants()

Convert `{e_XXXX}` shortcode paths to their equivalent constants. eg. `{e_PLUGIN}` becomes `e_PLUGIN`

```php
$tp->replaceConstants(string);
```

### parseTemplate()

Parse an e107 template using core and/or custom shortcodes. ie. replaces all instances of `{XXXXX_XXXX}` etc.

```php
$tp->parseTemplate($template, true, $custom_shortcodes);
```

| Parameter            | Type    | Description |
| -------------------- | ------- | ----------- |
| template             | string  | ...         |
| user core shortcodes | boolean | ...         |
| custom shortcodes    | object  | ...         |

### thumbUrl()

Use to convert `{e_MEDIA_IMAGE}` and other image paths to an auto-sized image path for use inside an `<img>` tag.

```php
$url   = "{e_MEDIA_IMAGE}2012-04/someimage.jpg";
$image = $tp->thumbUrl($url);

echo "<img src='".$image."' />
```

### setThumbSize()

Set the width, height and crop of the thumbUrl function.

```php
$tp->setThumbSize($width, $height, $crop);
```

### toGlyph()

Convert a glyph name into Html. Just choose an icon from [Font Awesome](https://fontawesome.com/icons?d=gallery) and remove the first 'fa'\
Templates may also use the following shortcode: which calls the same function.

```php
$tp->toGlyph("fa-anchor");
```

#### Advanced settings:

```php
$tp->toGlyph("fa-anchor", array('size'=>'2x'));
```

### toIcon()

Render an icon. If a .glyph extension is found, it will automatically use the toGlyph() function above.

```php
$iconPath = "{e_MEDIA}myicon.png";
$tp->toIcon($iconPath);
```

### toAvatar()

Render a user avatar. If empty, the current user's avatar will be displayed if found or a generic avatar image.

```php
echo $tp->toAvatar(); // render avatar of the current user. 
```

```php
$userData = e107::user(5);  // Get User data for user-id #5. 
echo $tp->toAvatar($userData); // requires as a minimum $userData['user_image'].
```

### toImage()

Render an image.

```php
$url = "{e_MEDIA_IMAGE}2012-04/someimage.jpg";
$parms = array('w'=>500, 'h'=>200,'crop'=>1, 'alt'=>'my image'); // if not width/height set, the default as set by {SETIMAGE} will be used.
echo $tp->toImage($url,$parms); 
```

### lanVars()

Used for [substitution](/plugin-development/internationalisation#substitution) of variables, in [language files](/plugin-development/internationalisation) for example.&#x20;

```php
define("LAN_EXAMPLE_01", "Update results: [x] records changed, [y] errors, [z] not changed");

$repl = array($changed, $errors, $unchanged);
$text = $tp->lanVars(LAN_EXAMPLE_01, $repl);
```

## Parser options

{% hint style="info" %}
**TODO:** Convert below code into readable tables with proper descriptions
{% endhint %}

```php
// Set up the defaults
	private $e_optDefault = array(
		// default context: reflects legacy settings (many items enabled)
		'context'      => 'OLDDEFAULT',
		//
		'fromadmin'    => false,

		// Enable emote display
		'emotes'       => true,

		// Convert defines(constants) within text.
		'defs'         => false,

		// replace all {e_XXX} constants with their e107 value - 'rel' or 'abs'
		'constants'    => false,

		// Enable hooked parsers
		'hook'         => true,

		// Allow scripts through (new for 0.8)
		'scripts'      => true,

		// Make links clickable
		'link_click'   => true,

		// Substitute on clickable links (only if link_click == TRUE)
		'link_replace' => true,

		// Parse shortcodes - TRUE enables parsing
		'parse_sc'     => false,

		// remove HTML tags.
		'no_tags'      => false,

		// Restore entity form of quotes and such to single characters - TRUE disables
		'value'        => false,

		// Line break compression - TRUE removes newline characters
		'nobreak'      => false,

		// Retain newlines - wraps to \n instead of <br /> if TRUE (for non-HTML email text etc)
		'retain_nl'    => false
	);

```

## Parser modifiers

{% hint style="info" %}
**TODO:** Convert below code into readable tables with proper descriptions
{% endhint %}

```php
// Super modifiers override default option values
	private $e_SuperMods = array(
		//text is part of a title (e.g. news title)
		'TITLE'        =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'emotes' => false, 'defs' => true, 'parse_sc' => true
			),
		'TITLE_PLAIN'  =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'emotes' => false, 'defs' => true, 'parse_sc' => true, 'no_tags' => true
			),
		//text is user-entered (i.e. untrusted) and part of a title (e.g. forum title)
		'USER_TITLE'   =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'scripts' => false, 'emotes' => false, 'hook' => false
			),
		// text is 'body' of email or similar - being sent 'off-site' so don't rely on server availability
		'E_TITLE'      =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'defs' => true, 'parse_sc' => true, 'emotes' => false, 'scripts' => false, 'link_click' => false
			),
		// text is part of the summary of a longer item (e.g. content summary)
		'SUMMARY'      =>
			array(
				'defs' => true, 'constants' => 'full', 'parse_sc' => true
			),
		// text is the description of an item (e.g. download, link)
		'DESCRIPTION'  =>
			array(
				'defs' => true, 'constants' => 'full', 'parse_sc' => true
			),
		// text is 'body' or 'bulk' text (e.g. custom page body, content body)
		'BODY'         =>
			array(
				'defs' => true, 'constants' => 'full', 'parse_sc' => true
			),
		// text is parsed by the Wysiwyg editor. eg. TinyMce
		'WYSIWYG'      =>
			array(
				'hook' => false, 'link_click' => false, 'link_replace' => false, 'retain_nl' => true
			),
		// text is user-entered (i.e. untrusted)'body' or 'bulk' text (e.g. custom page body, content body)
		'USER_BODY'    =>
			array(
				'constants' => 'full', 'scripts' => false, 'nostrip' => false
			),
		// text is 'body' of email or similar - being sent 'off-site' so don't rely on server availability
		'E_BODY'       =>
			array(
				'defs' => true, 'constants' => 'full', 'parse_sc' => true, 'emotes' => false, 'scripts' => false, 'link_click' => false
			),
		// text is text-only 'body' of email or similar - being sent 'off-site' so don't rely on server availability
		'E_BODY_PLAIN' =>
			array(
				'defs' => true, 'constants' => 'full', 'parse_sc' => true, 'emotes' => false, 'scripts' => false, 'link_click' => false, 'retain_nl' => true, 'no_tags' => true
			),
		// text is the 'content' of a link (A tag, etc)
		'LINKTEXT'     =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'emotes' => false, 'hook' => false, 'defs' => true, 'parse_sc' => true
			),
		// text is used (for admin edit) without fancy conversions or html.
		'RAWTEXT'      =>
			array(
				'nobreak' => true, 'retain_nl' => true, 'link_click' => false, 'emotes' => false, 'hook' => false, 'no_tags' => true
			),
		'NODEFAULT'    =>
			array('context' => false, 'fromadmin' => false, 'emotes' => false, 'defs' => false, 'constants' => false, 'hook' => false,
			      'scripts' => false, 'link_click' => false, 'link_replace' => false, 'parse_sc' => false, 'no_tags' => false, 'value' => false,
			      'nobreak' => false, 'retain_nl' => false
			)
	);
```


# Plugins

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

```php
$plg = e107::getPlug();
```

## Plugin methods

### load()

Load specified plugin data, can be used in conjunction with other methods.&#x20;

```php
$plg->load($plugdir)
```

| Parameter     | Type   | Description                                                                                                  | Mandatory? |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------ | ---------- |
| **plugindir** | string | <p>Plugin name. </p><p></p><p>Could also be <a href="/pages/-MVY9rLdcoMSgliaw5Cz">e\_CURRENT\_PLUGIN</a></p> | **Yes**    |

###


# Preferences

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

### Introduction

Use the following to retrieve the render class object.&#x20;

```php
$pref = e107::getPref();
```

### Retrieving preferences

Developers may retrieve admin preferences for their theme or plugin, or a core preference using the following method:

```php
e107::pref(type, value);
```

*Example: Load a stored value that was saved in the preferences admin area of the 'faqs' plugin*

```php
$faqPrefs = e107::pref('faqs'); // returns an array.
```

Or load a single preference value.

```php
$FaqPerPage = e107::pref('faqs', 'faqs_per_page');
```

| Type                     | Value (optional)                                       |
| ------------------------ | ------------------------------------------------------ |
| core                     | all core preference values.                            |
| theme                    | preferences of the currently selected front-end theme. |
| (any plugin folder name) | preferences of a particular plugin                     |


# Redirection

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

* You can redirect to a URL using the following static method:

```php
$url = "https://www.yourwebsite.com".
e107::redirect($url);
```

* To redirect to the homepage, simply leave the URL blank.

```php
e107::redirect();
```

* To redirect to the Admin Area, use the value 'admin'.

```php
e107::redirect('admin');
```


# Render

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Use the following to retrieve the render class object.&#x20;

```php
$ns = e107::getRender();
```

## Render methods

### tablerender()

Send HTML to the browser for output.&#x20;

```php
$ns->tablerender($caption, $text, $mode, $return);
```

| Parameter   | Type    | Description                                                                                                                    | Mandatory |
| ----------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ | --------- |
| **caption** | string  | Text for header/caption                                                                                                        | **Yes**   |
| **text**    | string  | Actual text/content                                                                                                            | **Yes**   |
| mode        | string  | <p>Unique name for what is being rendered. eg contact-menu<br>Used in themes and plugins. </p><p><em>Default:</em> default</p> | No        |
| return      | boolean | <p>When set to true the content is returned instead of being echoed</p><p><em>Default: false</em></p>                          | No        |


# Route

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

{% hint style="info" %}
&#x20;<https://github.com/e107inc/e107/issues/3912>
{% endhint %}


# URLs

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

You can generate a Search Engine Friendly (SEF) URLs using the following method:

```php
e107::url($plugin, $key, $row, $options);
```

<table><thead><tr><th>Parameter</th><th width="150">Type</th><th>Description</th><th>Mandatory?</th></tr></thead><tbody><tr><td>plugin</td><td>string</td><td>Folder name of the plugin. (will use data from <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_url-php">e_url.php</a>)</td><td><strong>Yes</strong></td></tr><tr><td>key</td><td>string</td><td>Unique key</td><td><strong>Yes</strong></td></tr><tr><td>row</td><td>array</td><td>Array of variable data such as id, title etc. eg. user_id, user_name</td><td>No</td></tr><tr><td>options</td><td>array</td><td><p>An associative array of additional options, with the following elements:</p><ul><li><strong>mode</strong>: abs | full (returning the absolute path or full URL)</li><li><strong>query</strong>: an array of query key/value-pairs (without any URL-encoding) to append to the URL.</li><li><strong>fragment</strong>: a fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.</li></ul><p><em>(optional)</em></p></td><td>No</td></tr></tbody></table>

## **Examples**

### **Example 1: Forum topic URLs**

In this example we will generate search-engine-friendly URLs for a forum topic with the following code: .

```php
// these values are usually loaded from the database. 
$data = array(
	'forum_sef'		=>	'my-sef-forum-name', 
	'thread_id'		=>  2, 
	'thread_sef'	=>	'my-forum-topic'
); 

$url = e107::url('forum','topic', $data);
```

The code above loads the following file: `e107_plugins/forum/e_url.php` and generates a URL from the following array data with the unique key `topic`:

```php
$config['topic'] = array(
	'regex'    => '^forum/(.*)/(d*)-([w-]*)/???(.*)',
	'sef'      => 'forum/{forum_sef}/{thread_id}-{thread_sef}/',
	'redirect' => '/e107_plugins/forum/forum_viewtopic.php?id=$2'
 );
```

Only the value of 'sef' is used in this array. it substitutes the values `{forum_sef},` `{thread_id}` and `{thread_sef}` with the variables in the `$data` array.

The end result would look something like this: <http://sitename.com/forum/my-sef-forum-name/2-my-forum-topic>

### Example 2: Using optional parameters

{% hint style="info" %}
**TODO: Add examples using the options parameter**
{% endhint %}


# User Data

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

&#x20;Returns an array of user data for a specific user. Input can be either a specific ID (`$user_id`) or use `USERID` for the currently logged in user.

```php
e107::user($user_id);

$userData = e107::user(USERID); // Example - currently logged in user. 
$userData = e107::user(5); // Example  User ID #5.
```

{% hint style="info" %}
todo: add example output
{% endhint %}


# Introduction

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

Plugins extended the functionality of e107 and allow for endless possibilities.&#x20;

CORE/THIRD PARTY - LINK TO USER GUIDE

## ARCHITECTURE&#x20;

The plugin architecture is developed to be as simple as possible. Often you can copy a file from an existing plugin and simply modify a few parameters in order to get similar functionality in your own plugin

## Folder structure

Example: blank plugin

* images
  * sizes?
* languages
  * English
    * ...
* templates
* addon files

Required files

* plugin.xml
*

Optional files

* admin\_config.php
* \*\_setup.php
* \*\_sql.php
* e\_\*.php addons
* \*\_shortcodes.php
*

## [ADMIN-UI ](/plugin-development/admin-ui)

## [addons](/plugin-development/extending-core-functionality-addons)


# Plugin Builder

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

By far, the quickest and easiest way to develop a plugin for e107 is to use the [Plugin Builder](/plugin-development/plugin-builder), because:

* It allows you to select the database file ([plugin\_sql.php](/plugin-development/installation-and-configuration#plugin_sql-php)) file from the plugin folder, or directly from the database table list, and it will generate most of the new code for the [Admin-UI](/plugin-development/admin-ui) of your plugin.<br>
* It will generate the new [plugin.xml](/plugin-development/installation-and-configuration#plugin-xml) meta-file, which is used during installation of your plugin and also when sharing plugins via this site.&#x20;

{% hint style="success" %}
The Plugin Builder can be found in Admin Area > Manage > Plugin Manager > Plugin Builder.&#x20;
{% endhint %}

## How to use the Plugin Builder

1. Create an empty plugin folder in e107\_plugins (eg. "*myplugin*")
2. Create a new text file with the \*\_sql.php extension. (eg. "*myplugin\_sql.php*")
3. Using a tool such as phpMyAdmin, create your database table structure, and then export it in SQL format.
4. Copy and paste the database structure *("CREATE TABLE")* to your your *\*\_sql.php* file. (see other plugins for examples)
5. Go to Admin Area > Manage > [Plugin Manager](https://userguide.e107.org/administration/manage/plugin-manager) > Plugin Builder and choose "*myplugin*" from the dropdown menu and then follow the prompts.
6. Thoroughly check the details of each Table Tab (and Preferences Tab if you need them) before proceeding with the creation process.

## Basic info

{% hint style="info" %}
This section has not been finished yet!
{% endhint %}

## Database tables

{% hint style="info" %}
This section has not been finished yet!
{% endhint %}

field

caption

type

data

width

batch

filter

inline

validate

display

R/O

Helptip

ReadParms

WriteParms

## Preferences

{% hint style="info" %}
This section has not been finished yet!
{% endhint %}

## Addons

{% hint style="info" %}
This section has not been finished yet!
{% endhint %}


# Admin-UI (User Interface)

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

The Admin-UI (Admin User Interface) is .....

{% hint style="info" %}
TODO: explain what it is and what it does
{% endhint %}

### Advantages of the Admin-UI

:thumbsup: The advantages of using the new [Admin-UI](/plugin-development/admin-ui) are numerous - including, but not limited to:

* No need to code in the HTML or the process of reading or writing to your database.
* Consistent interface with the rest of Admin Area
* Users can select which fields from your database table they wish to view - based on your predefined list.
* The Media-Manager is integrated into the system.
* Easily add drag and drop sorting/re-ordering to your plugin.
* Easily add batch functionality such as deleting, copying, featurebox creation, sitelink creation, userclass modification, etc.
* Easily add inline editing to your data.
* Easily add tabs to keep your plugin's admin-area well organized.

{% hint style="info" %}
:thumbsup: **TIP:** The [Plugin Builder](/plugin-development/plugin-builder) is very useful tool to use for the Admin-UI as it will generate most of the new code for the Admin-UI of your plugin.
{% endhint %}

{% content-ref url="/pages/-M8L7UlhkmSR6OQuNPAr" %}
[Plugin Builder](/plugin-development/plugin-builder)
{% endcontent-ref %}

### **File structure**

Below you can find the basic file structure of of the **admin\_config.php** file. This file serves the Admin-UI to the administrators.&#x20;

{% hint style="warning" %}
&#x20;It is strongly recommended to use **admin\_config.php** as the filename!&#x20;
{% endhint %}

```php
<?php

require_once("../../class2.php");
if (!getperms("P"))
{
	e107::redirect('admin');
	exit;
}


class plugin_blank_admin extends e_admin_dispatcher
{

	protected $menuTitle 	= 'blank Menu';
	protected $modes 		= array(...);
	protected $adminMenu 	= array(....);

	// optional
	protected $adminMenuAliases = array(...);
}
 

class plugin_blank_admin_ui extends e_admin_ui
{
	protected $pluginTitle 	= "...";
	protected $pluginName 	= '_blank';
	protected $table 		= "blank"; 
	protected $listQry 		= "";
	protected $listQry 		= "";
	protected $listOrder	= 'blank_id DESC';
	protected $listGroup	= 'somefield';  
	protected $pid 			= "blank_id";

	// optional
	// protected $perPage 			= 20;
	// protected $batchDelete 		= true;
	// protected \$sortField		= 'somefield_order';
	// protected \$sortParent      	= 'somefield_parent';
	// protected \$treePrefix      	= 'somefield_title';
	// protected $editQry 			= "SELECT * FROM #blank WHERE blank_id = {ID}";
	

	protected  $fields = array(...)


	//required - default column user prefs
	protected $fieldpref = array(...);
	protected $prefs = array(...);

	// optional
	public function init()
	{

	}
	
	
	public function customPage()
	{

	}

	public function beforePrefsSave($new_data, $old_data)
	{

	}
}

class plugin_blank_admin_form_ui extends e_admin_form_ui
{
	
	function blank_type($curVal, $mode) 
	{
		$frm = e107::getForm();
		
		$types = array('type_1'=>"Type 1", 'type_2' => 'Type 2');
		
		if($mode == 'read')
		{
			return vartrue($types[$curVal]).' (custom!)';
		}

		if($mode == 'batch') // Custom Batch List for blank_type
		{
			return $types;
		}

		if($mode == 'filter') // Custom Filter List for blank_type
		{
			return $types;
		}

		return $frm->select('blank_type', $types, $curVal);
	}
	
}

new plugin_blank_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();

require_once(e_ADMIN."footer.php");
```

## Classes, methods, variables

{% hint style="warning" %}
This section will summarize the various options which may be used while utilizing the Admin-UI class.&#x20;

**Please note that the documentation for this section is a work-in-progress.** \
Thank you for your patience!
{% endhint %}

### class plugin\_blank\_admin&#x20;

extends e\_admin\_dispatcher

#### $modes

...

####

### class plugin\_blank\_admin\_ui&#x20;

extends e\_admin\_ui

#### $fields

Database fields are defined by the `$fields` value in the Admin-UI class.&#x20;

*Example:*

```php
protected $fields = array(
	
	'myfield_id'  => array(
   		"title" 	=> "My Title", 
   		"type"		=> "text", 
   		"data"		=> "str", 
   		"width"		=> "auto", 
   		"inline"	=>	true
   	),

   // .....
);
```

| Key        | Format            | Description                                           |
| ---------- | ----------------- | ----------------------------------------------------- |
| title      | string            | Field Title                                           |
| type       | string            | Type of Field                                         |
| data       | string            | Data Type                                             |
| width      | string            | width of the column (List View)                       |
| inline     | boolean \| string | Enable or disable inline editing.                     |
| help       | string            | Popup helper text (tooltip)                           |
| readParms  | array             | Parameters specific to the 'list' mode.               |
| writeParms | array             | Parameters specific to the 'edit' and 'create' modes. |

#### type

| Type                   | Description                                                                            |
| ---------------------- | -------------------------------------------------------------------------------------- |
| text                   | text box                                                                               |
| number                 | text box (number)                                                                      |
| checkbox               | checkbox (0 or 1 is returned)                                                          |
| icon                   | icon (from media manager)                                                              |
| textarea               | text area (text only)                                                                  |
| boolean                | radio buttons with enable/disable                                                      |
| bbarea                 | right text area (html)                                                                 |
| dropdown               | dropdown list (ie. `<select></select>` )                                               |
| userclass              | drop-down list of userclasses                                                          |
| userclasses            | checkboxes for multiple userclasses                                                    |
| datestamp              | date / time text box                                                                   |
| user                   | user selection text box. (type 3 letters to find/search)                               |
| hidden                 | hidden field                                                                           |
| ip                     | text field with ip decoding                                                            |
| email                  | text field for email addresses                                                         |
| url                    | text field for urls (becomes clickable in list mode)                                   |
| password               | password field (with optional generator)                                               |
| image                  | Media-manager image selection tool for a single image                                  |
| images                 | Media-manager image selection tool for multiple images                                 |
| file                   | Media-manager file selection tool for a single file                                    |
| files                  | Media-manager file selection tool for multiple files                                   |
| media                  | Media-Manager selection tool for images, mp4, youtube and gylphs. (requires type=json) |
| method                 | custom method                                                                          |
| lanlist                | drop-down list of installed languages                                                  |
| language               | drop-down list of all languages                                                        |
| templates              | Dropdown list of templates (from a template file)                                      |
| null (without quotes)  | Ignore this field and do not save it's data                                            |
| false (without quotes) | Hide this field but save it's data if a posted key value is found.                     |

#### data

| Value             | Description                                                                                            |
| ----------------- | ------------------------------------------------------------------------------------------------------ |
| str               | Posted data is converted to string before saving to the database                                       |
| safestr           | Posted data is run through a filter (using `filter_var(FILTER_SANITIZE_STRING)`) and thus strips HTML. |
| int               | Posted data is converted to integer before saving to the database                                      |
| array             | Posted data is converted to an e107 array format. (use `e107::unserialize()` to decode)                |
| json              | Posted data is converted to json format before saving to the database                                  |
| false (no quotes) | Posted data from this field is not saved to the database                                               |

#### readParms (list mode)

| Key    | Value                                          | Field-type               | Comments                |
| ------ | ---------------------------------------------- | ------------------------ | ----------------------- |
| thumb  | (integer)                                      | image                    | Set the thumbnail width |
| url    | (string)  e\_url.php key value or a field key. | number, text, tags, null | Wrap value in a link    |
| target | (string) blank \| dialog                       | number, text, tags, null | Target for 'url' above. |

#### writeParms (create/edit mode)

| Key          | Value                                                                           | Field-type                           | Comments                                                                              |
| ------------ | ------------------------------------------------------------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------- |
| pre          | (html)                                                                          | (all)                                | Render html just before the field                                                     |
| post         | (html)                                                                          | (all)                                | Render html just after the field                                                      |
| media        | (string)                                                                        | bbarea                               | Sets the media-owner category to be used by the media-manager                         |
| video        | 0 or 1                                                                          | image                                | Show video selector tab in media-manager                                              |
| path         | 'plugin' or null                                                                | image                                | When set to 'plugin', images will be stored in the 'plugin' folder within e107\_media |
| glyphs       | 0 or 1                                                                          | icon                                 | Show glyph selector tab in media-manager                                              |
| size         | large, xlarge, xxlarge, block-level                                             | text, url, email, textarea, dropdown | Set the size (width) of input field                                                   |
| optArray     | (array of key=>value pairs)                                                     | dropdown, checkboxes                 | Set the keys/values to be used in the dropdown or checkboxes.                         |
| placeholder  | (string)                                                                        | text, url, email, textarea           | Placeholder text                                                                      |
| pattern      | (regexp)                                                                        | text, url, email                     | Regular expression validation                                                         |
| type         | date or datetime                                                                | datestamp                            | Choose between date or date and time                                                  |
| readonly     | 0 or 1                                                                          | datestamp                            | Make element read-only                                                                |
| auto         | 0 or 1                                                                          | datestamp                            | Insert current date/time automatically                                                |
| label        | yesno                                                                           | boolean                              | Change "Enabled" and "Disabled" to "Yes" and "No".                                    |
| inverse      | 0 or 1                                                                          | boolean                              | Invert the values of 0 and 1. ie. "Disabled" = 1 and "Enabled" = 0.                   |
| enabled      | (string)                                                                        | boolean                              | Alternate text to replace "Enabled"                                                   |
| disabled     | (string)                                                                        | boolean                              | Alternate text to replace "Disabled"                                                  |
| classlist    | <p>public, guest, nobody, member, admin, main, classes<br>(comma separated)</p> | userclass                            | Set which userclasses should be displayed.                                            |
| tdClassLeft  | (string)                                                                        | (all)                                | Set the css class for the left-side table cell.                                       |
| tdClassRight | (string)                                                                        | (all)                                | Set the css class for the right-side table cell.                                      |
| trClass      | (string)                                                                        | (all)                                | Set the css class for the table row.                                                  |
| nolabel      | 0 or 1                                                                          | (all)                                | Hide the left table cell                                                              |

## Creating a tree structure

The Admin-UI allows to automatically create a tree structure based on parent/child relationship tables.  In order to add a tree structure, add the following code:

```php
protected $sortField  = 'field1';
protected $sortParent = 'field2';
protected $treePrefix = 'field3';
```

In this case:

* `field1` represents the field which determines the order (for example an ID field).&#x20;
* `field2` represents the field which is the parent&#x20;
* `field3` represents the field which is the child

### Examples

{% hint style="info" %}
Examples can be found in the forum and download plugin.
{% endhint %}

```php
protected $sortField  = 'download_category_order';
protected $sortParent = 'download_category_parent';
protected $treePrefix = 'download_category_name';
```


# Installation & configuration

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

## Folder structure & files

The table below lists the files that can be used in a plugin. Only few of them are mandatory.&#x20;

{% hint style="info" %}
**Note:** Please replace the cursive *plugin* with the name of the plugin folder. \
(\**menu.php, \*\_setup.php, \*\_shortcodes.php, \*\_sql.php).*&#x20;
{% endhint %}

{% hint style="success" %}
**TIP:** the \_blank plugin contains useful examples as reference material.&#x20;
{% endhint %}

<table><thead><tr><th width="249.33333333333331">Filename / Foldername</th><th>Description</th><th>Mandatory?</th></tr></thead><tbody><tr><td>languages<br><em>(folder)</em></td><td>Contains the <a href="/pages/-M8L8W_7ppyk2VMmNhSr">language files</a></td><td><strong>English language files</strong> </td></tr><tr><td>templates <br><em>(folder)</em></td><td></td><td></td></tr><tr><td><a href="/pages/-M8L8GkIwhEeyiatLNRC#plugin-xml">plugin.xml</a></td><td>Contains all the meta data needed for the plugin to be installed and configured on a basic level. </td><td><strong>Yes</strong></td></tr><tr><td><a href="#plugin_menu.php"><em>plugin</em>_menu.php</a></td><td></td><td>No</td></tr><tr><td><a href="/pages/-M8L8GkIwhEeyiatLNRC#plugin_setup-php"><em>plugin</em>_setup.php</a></td><td>Allow to run code before or after (un)installing the plugin, or to set checks for newer plugin versions. <br></td><td>No</td></tr><tr><td><a href="#undefined"><em>plugin</em>_shortcodes.php</a></td><td>...<br></td><td>No</td></tr><tr><td><a href="/pages/-M8L8GkIwhEeyiatLNRC#plugin_sql-php"><em>plugin</em>_sql.php</a></td><td>Contains the database structure.</td><td>No</td></tr><tr><td><a href="#undefined">admin_config.php</a></td><td>Contains the <a href="/pages/-M8AVDQ4CL_ofKpUF9gG">Admin UI </a>configuration.</td><td>No</td></tr><tr><td>e_*.php addons</td><td><a href="/pages/-M8L14wz7KtpK1CWoDWE">See addons</a>.</td><td>No</td></tr></tbody></table>

## plugin.xml

### Elements & attributes

<table><thead><tr><th width="199">Element</th><th width="150">Sub</th><th width="150">Attributes</th><th width="196.40740740740745">Text / Value</th><th width="150">Mandatory?</th></tr></thead><tbody><tr><td><strong>&#x3C;e107Plugin></strong></td><td></td><td></td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>name</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>version</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>date</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>lan</td><td></td><td>No</td></tr><tr><td></td><td></td><td>compatibility</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>installRequired</td><td></td><td><strong>Yes</strong></td></tr><tr><td><strong>&#x3C;author></strong></td><td></td><td>name</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>url</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>email</td><td></td><td><strong>Yes</strong></td></tr><tr><td><strong>&#x3C;description></strong></td><td></td><td></td><td>Textual description of the plugin</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>lan</td><td>LAN reference to the description</td><td>No</td></tr><tr><td>&#x3C;copyright></td><td></td><td></td><td>Copyright text</td><td>?</td></tr><tr><td><strong>&#x3C;category></strong></td><td></td><td></td><td>Plugin category.  Choose from:<br>- <code>settings</code><br>- <code>users</code><br>- <code>content</code><br>- <code>tools</code><br>- <code>manage</code><br>- <code>misc</code><br>- <code>menu</code><br>- <code>about</code></td><td><strong>Yes</strong></td></tr><tr><td>&#x3C;keywords></td><td></td><td></td><td></td><td>No</td></tr><tr><td>    </td><td>&#x3C;word></td><td></td><td>Keyword</td><td>No</td></tr><tr><td>&#x3C;adminLinks></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;link></td><td></td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>url</td><td>URL of the link</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>description</td><td>Description of the link</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>icons</td><td>icon path</td><td><strong>Yes</strong></td></tr><tr><td>&#x3C;sitelinks></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;link></td><td></td><td>Link name</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>url</td><td>URL of the link</td><td><strong>Yes</strong></td></tr><tr><td>&#x3C;pluginPrefs></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;pref></td><td></td><td>Value of the pref</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>name</td><td>Name of the pref</td><td><strong>Yes</strong></td></tr><tr><td>&#x3C;dependencies></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;plugin></td><td></td><td></td><td>No</td></tr><tr><td></td><td></td><td>name</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>min_version</td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;PHP></td><td></td><td></td><td>No</td></tr><tr><td></td><td></td><td>name</td><td></td><td><strong>Yes (= core)</strong></td></tr><tr><td></td><td></td><td>min_version</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td>&#x3C;MySQL></td><td></td><td></td><td>No</td></tr><tr><td></td><td></td><td>name</td><td></td><td><strong>Yes (= server)</strong></td></tr><tr><td></td><td></td><td>min_version</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td>&#x3C;extension></td><td></td><td></td><td>No</td></tr><tr><td></td><td></td><td>name</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>min version</td><td></td><td>No</td></tr><tr><td>&#x3C;userClasses></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;class></td><td></td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>name</td><td>class_name (lowercase)</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>description</td><td>Description of the userclass</td><td><strong>Yes</strong></td></tr><tr><td>&#x3C;extendedFields></td><td></td><td></td><td></td><td>No</td></tr><tr><td></td><td>&#x3C;field></td><td></td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>name</td><td>Name of the EUF</td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>type</td><td><p>Type of the EUF. Choose from:</p><ul><li>EUF_TEXT</li><li>EUF_RADIO</li><li>EUF_DROPDOWN</li><li>EUF_DB_FIELD</li><li>EUF_TEXTAREA</li><li>EUF_INTEGER</li><li>EUF_DATE</li><li>EUF_LANGUAGE</li><li>EUF_PREDEFINED</li><li>EUF_CHECKBOX</li><li>EUF_PREFIELD</li><li>EUF_ADDON</li><li>EUF_COUNTRY</li><li>EUF_RICHTEXTAREA</li></ul></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>default</td><td></td><td><strong>Yes</strong></td></tr><tr><td></td><td></td><td>active</td><td>true/false</td><td><strong>Yes</strong></td></tr></tbody></table>

### Examples

#### Simple&#x20;

```markup
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="Newsfeeds" version="2.0" date="2012-08-01" compatibility="2.0" installRequired="true">
	<author name="e107 Inc." url="http://e107.org" email="@" />
	<description>This plugin's description.</description>
	<category>content</category>
	<adminLinks>
		<link url='admin_config.php' description='Configure Newsfeeds' icon='images/icon_32.png' iconSmall='images/icon_16.png' >LAN_CONFIGURE</link>	
	</adminLinks>
	<siteLinks>
		<link url="/e107_plugins/newsfeed/newsfeed.php" >Newsfeeds</link>
	</siteLinks>	
</e107Plugin>
```

#### Advanced

```markup
<?xml version="1.0" encoding="utf-8"?>
<e107Plugin name="FAQs" version="1.1"  lan="LAN_PLUGIN_XXX_NAME" date="2012-08-01" compatibility="2.0" installRequired="true">
	 <author name="e107 Inc" url="http://www.e107.org" email="@" />
	<summary>Add frequently asked questions to your e107 website.</summary>
	<description  lan="LAN_PLUGIN_XXX_DESCRIPTION">A simple plugin to add Frequently Asked Questions to your website.</description>
	 <copyright>Copyright e107 Inc e107.org, Licensed under GPL</copyright>
	<category>content</category>
	<keywords>
		<word>faq</word>
		<word>question</word>
		<word>answer</word>
	</keywords>
	<adminLinks>
		<link url='admin_config.php' description='Configure FAQs' icon='images/icon_32.png' iconSmall='images/icon_16.png' primary='true'>LAN_CONFIGURE</link>		
	</adminLinks>
	<siteLinks>
		<link url='/e107_plugins/faqs/faqs.php' description='FAQs' icon='images/icon_32.png' iconSmall='images/icon_16.png' function="faqCategories">LAN_PLUGIN_FAQS_NAME</link>		
	</siteLinks>
	<pluginPrefs>
		<pref name="add_faq">255</pref>
		<pref name="submit_question">255</pref>
		<pref name="classic_look">0</pref>
	</pluginPrefs>
	<dependencies>
		<plugin name='chatbox_menu' />
		<plugin name='calendar_menu' min_version='3.70' />
		<PHP name='core' min_version='5.2.5' />
		<MySQL name='server' min_version='4.9' />
		<extension name='curl' min_version='1.3' />
		<extension name='mb_string' />
	</dependencies>
	<userClasses>
		<class name="faq_moderator" description="FAQ moderator" />		
	</userClasses>
	<extendedFields>
		<field name="viewed" type='EUF_TEXTAREA' default='0' active="true" />
		<field name="posts" type='EUF_INTEGER' default='0' active="true" />
	</extendedFields>	
</e107Plugin>
```

### **Commercial plugins**

Commercial plugins can make use of a few extra attributes to the \<e107Plugin> element, so that this information will be displayed correctly in the admin area under :point\_right: "[Find Plugins](https://userguide.e107.org/administration/manage/plugin-manager#find-plugins)".&#x20;

| Attribute | Description                                                                                                                                                                                                                                                                                                                                                                       |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Price     | <p>Purchasing price of the plugin (in xx.xx format). <br><br><em>Example: 25.00</em></p>                                                                                                                                                                                                                                                                                          |
| Currency  | <p>Currency codes (ISO 4217)<br><br><em>Example: EUR</em></p>                                                                                                                                                                                                                                                                                                                     |
| URL       | <p>Direct path to the website page where the plugin can be purchased. When the user clicks to download your plugin, the URL will be displayed.</p><p></p><p><span data-gb-custom-inline data-tag="emoji" data-code="2757">❗</span><em>Note: do not add the URL to the generic homepage of your website, but only the URL to the specific page for that specific plugin.</em> </p> |

#### Example

```markup
<e107Plugin name="FAQs" .... price="25.00" currency="EUR" url="http://direct-path-to-my-plugin-purchase-page.com" >
```

## *plugin*\_menu.php

....

## *plugin*\_setup.php

{% hint style="info" %}
Do not forget to use your plugin name in the filename, e.g. "*myplugin\_setup.php*"
{% endhint %}

{% hint style="info" %}
TODO: Add this section, provide example.&#x20;
{% endhint %}

## *plugin\_shortcodes.php*

Please refer to the [Plugin shortcodes](#plugin_shortcodes.php) page

{% content-ref url="/pages/-MUU-xAktEgx\_STyxzDR" %}
[Plugin shortcodes](/plugin-development/plugin-shortcodes)
{% endcontent-ref %}

## *plugin*\_sql.php

{% hint style="info" %}
Do not forget to use your plugin name in the filename, e.g. "*myplugin\_sql.php*"
{% endhint %}

This file contains the SQL database structure of the plugin. It will be analyzed on plugin install and missing tables will be installed automatically.&#x20;

Any differences between the defined structure here and the table structure on the server will be detected and the user will be informed in the Admin Area.&#x20;

{% hint style="success" %}
:thumbsup:**TIP:** To check if the table structure is still valid, run  :point\_right:"Admin Area > Tools > Database > [Check for Updates](https://userguide.e107.org/administration/tools/database#check-for-updates)"&#x20;
{% endhint %}

### Supported operations

For the moment, the following operations are supported:

* Create table
* Change field type, field size, field null or not, field default value
* Add index

### Unsupported operations

Operations that are currently NOT supported are:

* **Rename table:** by renaming the tablename, e.g. "blank" > "blank2"). The renamed table will be considered as new!
* **Drop a table:** e.g. if you remove the "blank" table definition from this file, the table will NOT be deleted from the database!)
* **Rename or drop a field:** a renamed field will be considered new, a missing field definition will NOT be recognized at all!
* **Change an index/key:** the change is recognized, but leads to an error message and the change is not applied.&#x20;
* **Rename or drop an index/key:** rename is recognized as a new index and the missing index is not recognized at all!)
* A field definition containing "NULL DEFAULT NULL". The "Check for updates" method will always detect a change.&#x20;
* but fails silently when trying to update. In that case remove the first "NULL" and run the the "Check for updates" again.

{% hint style="success" %}
:thumbsup:**TIP:** Check the *blank\_setup.php* file or the forum\_setup.php file for examples on renaming/dropping/modifying tables, fields and indexes.&#x20;
{% endhint %}

### Example

```sql
CREATE TABLE blank (
  `blank_id` int(10) NOT NULL AUTO_INCREMENT,
  `blank_icon` varchar(255) NOT NULL,
  `blank_type` varchar(10) NOT NULL,
  `blank_name` varchar(50) NOT NULL,
  `blank_folder` varchar(50) DEFAULT NULL,
  `blank_version` varchar(5) NOT NULL,
  `blank_author` varchar(50) NOT NULL,
  `blank_authorURL` varchar(255) NOT NULL,
  `blank_date` int(10) NOT NULL,
  `blank_compatibility` varchar(5) NOT NULL,
  `blank_url` varchar(255) NOT NULL,
  `blank_media` json DEFAULT NULL,
  `blank_class` int(10) NOT NULL,
  PRIMARY KEY (`blank_id`)
) ENGINE=MyISAM;
```

## admin\_config.php

Please refer to the[ Admin-UI (User Interface) page. ](/plugin-development/admin-ui)

{% content-ref url="/pages/-M8AVDQ4CL\_ofKpUF9gG" %}
[Admin-UI (User Interface)](/plugin-development/admin-ui)
{% endcontent-ref %}


# Plugin shortcodes

## myplugin\_shortcodes.php


# Internationalisation (LAN)

## Introduction

Your website can be used in different languages. In order for your plugin or theme areas to be displayed in a specific language, it needs to be translated.&#x20;

{% hint style="warning" %}
:thumbsup: **You should always include the English language files in your plugin!**
{% endhint %}

## Language files

### File Types

There are three types of language files that can be used in your plugin.&#x20;

| Language File       | Usage                                                                                                                                                                                                                                        |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| English\_front.php  | Used **only** for the frontend of your plugin                                                                                                                                                                                                |
| English\_admin.php  | Used **only** for the Admin Area of your plugin                                                                                                                                                                                              |
| English\_global.php | Used site-wide, for example in :point\_right: [plugin.xml](/plugin-development/installation-and-configuration#plugin-xml),  files such as`xxxx_menu.php`or :point\_right: [addons](/plugin-development/extending-core-functionality-addons). |

## Defining Language Terms&#x20;

Language Terms are more commonly known as *LAN's.* You can define LAN's by using PHP constants:

```php
define("LAN_PLUGIN_MYPLUGIN_NAME", "Blank Plugin");
define("LAN_PLUGIN_MYPLUGIN_DIZ",  "A Blank Plugin to help you get started in plugin development. More details can be added here."); 
define("LAN_PLUGIN_MYPLUGIN_LINK", "Blank Link");
```

### Best practices

:thumbsup: **Always use the format LAN\_PLUGIN\_{FOLDER}\_{TYPE} to prevent conflicts.**&#x20;

#### Avoid duplicating terms, particularly in the admin area.&#x20;

:thumbsup: If defining terms for admin, always search `lan_admin.php` for existing LANs which may match what you require.&#x20;

#### Never use HTML or URLs inside LAN definitions.&#x20;

:thumbsup: Use double quotes within the defines and use `str_replace()` or :point\_right: [lanVars()](/classes-and-methods/parser#lanvars) for [variables ](/plugin-development/internationalisation#substitution)where needed.&#x20;

#### Avoid short language strings for common words&#x20;

Examples are words such as '*and*', '*to*' and so on. There aren't always equivalents in other languages.

:thumbsup: If embedding values into a phrase, use [substitution](/plugin-development/internationalisation#substitution).&#x20;

#### Avoid using [substitution](/plugin-development/internationalisation#substitution) terms which are real words or known BBCodes.

:thumbsup: Use brackets `[..]` and values such as x, y, z. See [examples ](/plugin-development/internationalisation#examples)below.&#x20;

### Examples

#### **Good**

```php
define("LAN_XXX", "Thank you Firstname");
define("LAN_XXX", "Go to [x] to see the results."); // Good - replace [ and ] with <a href='...'> and </a> using str_replace()
define("LAN_XXX", "I want to [quote] here"); // Good - replace [ and ] with " " using str_replace()
```

#### **Bad**

```php
define("LAN_XXX", "Thank you <b>Firstname</b>"); // Bad contains HTML
define("LAN_XXX", "Thank you <a href='http://somewhere.com'>Firstname</a>"); // Bad contains HTML and allows translator to modify link.
```

#### **Substitution**&#x20;

```php
define("LAN_EXAMPLE_01", "Update results: [x] records changed, [y] errors, [z] not changed");

$repl = array($changed, $errors, $unchanged);
$text = e107::getParser()->lanVars(LAN_EXAMPLE_01, $repl);
```

## Loading Language Files

### e107::lan()

To load a language file from a plugin folder, use `e107::lan()`:

```php
e107::lan('faqs');
e107::lan('faqs', true);
e107::lan('faqs', false, true);
e107::lan('faqs', true, true);
```

This will include the following paths:

```
e107_plugins/faqs/languages/English_front.php
e107_plugins/faqs/languages/English_admin.php
e107_plugins/faqs/languages/English/English_front.php
e107_plugins/faqs/languages/English/English_admin.php
```


# Extending core functionality (addons)

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

There are several ways to extend the core functionality of e107. One of those ways is by using so-called "addons". These addons are files which reside in each plugin's folder and allow a plugin to embed itself inside e107's core pages and functions.

The addons can be recognised by their `e_xxxxx.php` naming format. By simply placing them inside your plugin's folder, they will be auto-detected during installation and integrated into the system.

{% hint style="warning" %}
**Please note:** If addons are added after plugin installation, you may need to run the :point\_right: "[Scan plugin directories](https://userguide.e107.org/administration/tools/database#scan-plugin-directories)" option in Admin Area > Tools > [Database](https://userguide.e107.org/administration/tools/database).&#x20;
{% endhint %}

{% hint style="info" %}
**TIP:** The `_blank` plugin in the e107\_plugins folder contains example addons that may be an easy reference for you.&#x20;
{% endhint %}

### Overview of all plugin addons

| Name                               | Description                                                                                                                                                                                                                                                                          |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [e\_admin](#e_admin.php)           | Allows to extend areas of the [Admin UI](/plugin-development/admin-ui)                                                                                                                                                                                                               |
| [e\_bb](#e_bb.php)                 | Allows a plugin to add customized BBCodes.                                                                                                                                                                                                                                           |
| [e\_comment](#e_comment.php)       | Allows a plugin to override the default :point\_right:[comments 'engine'](https://userguide.e107.org/administration/manage/comments-manager#engine)                                                                                                                                  |
| [e\_cron](#e_cron.php)             | Allows a plugin to add additional :point\_right:[Scheduled Tasks](https://userguide.e107.org/administration/tools/schedule-tasks) (or 'cronjobs') to e107.                                                                                                                           |
| [e\_dashboard](#e_dashboard.php)   | Adds custom plugin information to the dashboard of e107's admin area.                                                                                                                                                                                                                |
| [e\_emailprint](#e_emailprint.php) | <p><strong>Deprecated!</strong> <br>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_print-php">e\_print</a> instead.</p>                                                                                                                                                                  |
| [e\_event](#e_event.php)           | Allows a plugin to easily hook into system events and trigger their own methods/functions.                                                                                                                                                                                           |
| [e\_featurebox](#e_featurebox.php) | Allows a plugin to generate content for the :point\_right:[Featurebox plugin](https://userguide.e107.org/core-plugins/featurebox).                                                                                                                                                   |
| [e\_footer](#e_footer.php)         | Allows a plugin to include code in the footer of every page of the site                                                                                                                                                                                                              |
| [e\_frontpage](#e_frontpage.php)   | Allows a plugin developer to add their plugin as a :point\_right:[Frontpage](https://userguide.e107.org/administration/settings/front-page) option.                                                                                                                                  |
| [e\_gsitemap](#e_gsitemap.php)     | Allows a plugin to create automated entries for the :point\_right:[Google Sitemap plugin](https://userguide.e107.org/core-plugins/google-sitemap).                                                                                                                                   |
| [e\_header](#e_header.php)         | Allows a plugin developer to add data to `<head>` of every page.                                                                                                                                                                                                                     |
| [e\_help](#e_help.php)             | <p><strong>Deprecated!</strong> </p><p>Allowed plugin developers to add information to the plugin configuration page <em>sidebar</em>. This has now been integrated within the <a href="/pages/-M8AVDQ4CL_ofKpUF9gG">Admin-UI</a> through the <code>renderHelp()</code> method. </p> |
| [e\_latest](#e_latest.php)         | <p><strong>Deprecated!</strong> <br>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_dashboard-php">e\_dashboard</a> instead.</p>                                                                                                                                                          |
| [e\_library](#e_library.php)       | Allows a plugin to include a third-party library.                                                                                                                                                                                                                                    |
| [e\_linkgen](#e_linkgen.php)       | <p><strong>Deprecated!</strong> </p><p>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_sitelink-php">e\_sitelink</a> instead.</p>                                                                                                                                                         |
| [e\_list](#e_list.php)             | Allows a plugin to hook into the :point\_right:[List Latest plugin](https://app.gitbook.com/@e107/s/user-guide/core-plugins/list-latest)                                                                                                                                             |
| [e\_mailout](#e_mailout.php)       | Allows a plugin to use e107's mailout feature for bulk mailing.                                                                                                                                                                                                                      |
| [e\_menu](#e_menu.php)             | Provide configuration options for each instance of the plugin's menus.                                                                                                                                                                                                               |
| [e\_meta](#e_meta.php)             | <p><strong>Deprecated!</strong> </p><p>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_header-php">e\_header</a> instead.</p>                                                                                                                                                             |
| [e\_module](#e_module.php)         | Is loaded every time the core of e107 is included and allows a developer to modify or define code which should be loaded prior to the header or anything that is sent to the browser as output.                                                                                      |
| [e\_notify](#e_notify.php)         | Adds a plugin to the [notifications](https://userguide.e107.org/administration/tools/notify) section in e107's admin area.                                                                                                                                                           |
| [e\_output](#e_output.php)         | Allows a plugin to hook into all pages at the end (after closing `</html>`)                                                                                                                                                                                                          |
| [e\_parse](#e_parse.php)           | Allows a plugin to hook into e107's [parser methods](/classes-and-methods/parser#parser-methods)                                                                                                                                                                                     |
| [e\_print](#e_print.php)           | Allows a plugin developer to specify content that is displayed in printer-friendly format.                                                                                                                                                                                           |
| [e\_rss](#e_rss.php)               | Adds a plugin to the RSS plugin, and generates RSS feeds.                                                                                                                                                                                                                            |
| [e\_related](#e_related.php)       | Adds a plugin to the search which generates 'related' links in news items and pages.                                                                                                                                                                                                 |
| [e\_search](#e_search.php)         | Adds a plugin to the :point\_right:[Search page](https://userguide.e107.org/administration/settings/search).                                                                                                                                                                         |
| [e\_shortcode](#e_shortcode.php)   | Allows a plugin to make their shortcodes available to core templates and templates of other plugins.                                                                                                                                                                                 |
| [e\_sitelink](#e_sitelink.php)     | Allows a plugin to automatically generate :point\_right:[Navigation](https://userguide.e107.org/administration/settings/navigation) links                                                                                                                                            |
| [e\_status](#e_status.php)         | <p><strong>Deprecated!</strong><br>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_dashboard-php">e\_dashboard</a> instead.</p>                                                                                                                                                           |
| [e\_tohtml](#e_tohtml.php)         | <p><strong>Deprecated!</strong><br>Use <a href="/pages/-M8L14wz7KtpK1CWoDWE#e_parse-php">e\_parse</a> instead.</p>                                                                                                                                                                   |
| [e\_upload](#e_upload.php)         | Allows a plugin to set categories for :point\_right:[Public Uploads](https://userguide.e107.org/administration/content/public-uploads)                                                                                                                                               |
| [e\_url](#e_url.php)               | Provides a simple way to add mod-rewrite redirects to  a plugin's page. Used to create  search-engine-friendly URLs through the [e107::url()](/classes-and-methods/urls) method.                                                                                                     |
| [e\_user](#e_user.php)             | Adds information about a specific user to the user's profile page, allows to add fields to the user settings page and allows to specify a routine that is run upon user deletion.                                                                                                    |

## Plugin addons&#x20;

{% hint style="warning" %}
:thumbsup: Be sure to replace `plugindir` with your plugin's directory name in all examples below.
{% endhint %}

### e\_admin.php

{% hint style="info" %}
**TODO**: Add example. See social plugin for an example.&#x20;
{% endhint %}

### e\_bb.php

{% hint style="info" %}
**TODO**: Add example.
{% endhint %}

### e\_comment.php

{% hint style="info" %}
**TODO**: Add example. See social plugin for an example.&#x20;
{% endhint %}

### e\_cron.php

This addon allows a plugin to add additional scheduled task options to e107. (see Admin Area > Tools > [Scheduled Tasks](https://userguide.e107.org/administration/tools/schedule-tasks)).&#x20;

#### *Example:*

```php
class plugindir_cron   // plugin-folder name + '_cron'
{
    function config() // Setup  
    {
        $cron = array();
	
        $cron[] = array(
            'name'            => "Name of my function",  // Displayed in admin area. . 
            'function'        => "myFunction",    // Name of the function which is defined below. 
            'category'        => 'mail',           // Choose between: mail, user, content, notify, or backup
            'description'     => "Description of what my function does"  // Displayed in admin area. 
        );		
		
        return $cron;
    }
	
    public function myFunction()
    {
        // Do something. 
    }

}
```

### e\_dashboard.php

This addon adds custom plugin information to the dashboard of e107's admin area. The 'latest', 'status' and 'website stats' areas may all contain information from your plugin.

{% hint style="info" %}
Previously, the `e_latest` and `e_status` addons were used separately for this. They have now been incorporated into the e\_dashboard addon.&#x20;
{% endhint %}

#### &#x20;*Example:*

```php
class plugindir_dashboard // plugin-folder name + '_dashboard'
{
	private $title; // dynamic title.
	
	function chart()
	{
		$config = array();

		$config[] = array(
			'text'		=> $this->activity(),
			'caption'	=> $this->title,
		);

		return $config;
	}

	/**
	 * Non-functional example.
	 */
	function activity()
	{
		// do something
	}
		
	function status() // Status Panel in the admin area
	{
		$var[0]['icon'] 	= "<img src='".e_PLUGIN."plugindir/images/blank_16.png' alt='' />";
		$var[0]['title'] 	= "My Title";
		$var[0]['url']		= e_PLUGIN_ABS."plugindir/plugin.php";
		$var[0]['total'] 	= 10;

		return $var;
	}	
	
	function latest() // Latest panel in the admin area.
	{
		$var[0]['icon'] 	= "<img src='".e_PLUGIN."plugindir/images/blank_16.png' alt='' />";
		$var[0]['title'] 	= "My Title";
		$var[0]['url']		= e_PLUGIN_ABS."plugindir/plugin.php";
		$var[0]['total'] 	= 10;

		return $var;
	}	
}
```

### e\_emailprint.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_print.php](/plugin-development/extending-core-functionality-addons#e_print-php) instead.&#x20;
{% endhint %}

### e\_event.php

This addon allows a plugin to easily hook into system events and trigger their own methods and functions using data provided by those events.

{% hint style="success" %}
You can make use of the [event methods](https://devguide.e107.org/classes-and-methods/events#events-methods) and [event triggers](https://devguide.e107.org/classes-and-methods/events#event-triggers).
{% endhint %}

#### *Example:*

```php
class plugindir_event // plugin-folder + '_event'
{
	function config()
	{
		$event = array();		

		// Hook into a core event, in this case "login". 
		$event[] = array(
			'name'		=> "login", // when this is triggered... 
			'function'	=> "myfunction", // ..run this function (see below).
		);
		
		// Hook into a custom plugin event (created by that plugin author)
		$event[] = array(
			'name'		=> "pluginfolder_customevent", // hook into a custom plugin event
			'function'	=> "otherfunction", // ..run another function (see below).
		);

		return $event;
	}

	function myfunction($data) // the method to run.
	{
		// var_dump($data);
	}
	
	function otherfunction($data) // the method to run.
	{
		// var_dump($data);
	}
}
```

### e\_featurebox.php

{% hint style="info" %}
**TODO:** Add example.
{% endhint %}

### e\_footer.php

This addon allows a plugin to include code in the footer of every page of the site.

{% hint style="info" %}
Please find an example in the "tinymce4" plugin.&#x20;
{% endhint %}

### e\_frontpage.php

This addon allows a plugin developer to add their plugin as a :point\_right:[Frontpage](https://userguide.e107.org/administration/settings/front-page) option.

#### ***Example:***

```php
class plugindir_frontpage // plugin-folder + '_frontpage'
{
	// Option 1: individual item
	function config()
	{

		$frontPage = array(
			'page' 	=> '{e_PLUGIN}_blank/_blank.php', 
			'title' => LAN_PLUGIN__BLANK_NAME
		);

		return $frontPage;
	}

	
	// Option 2: multiple items
	function config()
	{
		$config = array();

		$config['title']    = LAN_PLUGIN__BLANK_NAME;
		$config['page']     = array(
			0   => array(
				'page' => '{e_PLUGIN}_blank/_blank.php', 
				'title'=>'Main Page'
			),
		);

		return $config;
	}
}
```

### e\_gsitemap.php

{% hint style="info" %}
**TODO:** Add example. See "news" plugin folder for an example.&#x20;
{% endhint %}

### e\_header.php

This addon allows a plugin developer to add data to the `<head>` of every page. This file is loaded in the header of each page of your site. ie. Wherever you see `require_once(HEADERF)` in a script.\
\
Typically you would use one or all of the following functions within this file: [`e107::js()`](/classes-and-methods/javascript), [`e107::css()`](/classes-and-methods/css) or [`e107::meta()`](/classes-and-methods/meta)

{% hint style="danger" %}
**Warning:** Output should never be echoed or printed from this file!
{% endhint %}

#### *Example:*

```php
if(deftrue('USER_AREA')) // prevents inclusion of JS/CSS/meta in the admin area.
{
	e107::js('_blank', 'js/blank.js');      // loads e107_plugins/_blank/js/blank.js on every page.
	e107::css('_blank', 'css/blank.css');    // loads e107_plugins/_blank/css/blank.css on every page
	e107::meta('keywords', 'blank,words');   // sets meta keywords on every page.
}
```

### e\_help.php

{% hint style="warning" %}
**Deprecated!** \
This addon allowed plugin developers to add information to the plugin configuration page *sidebar*. \
\
This has now been integrated within the [Admin-UI](/plugin-development/admin-ui) through the `renderHelp()` method.&#x20;
{% endhint %}

### e\_latest.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_dashboard.php](/plugin-development/extending-core-functionality-addons#e_dashboard-php) instead.&#x20;
{% endhint %}

### e\_library.php

{% hint style="info" %}
Please find an example in the "\_blank" plugin.&#x20;
{% endhint %}

### e\_linkgen.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_sitelink.php](/plugin-development/extending-core-functionality-addons#e_sitelink-php) instead.&#x20;
{% endhint %}

### e\_list.php

{% hint style="info" %}
**TODO:** Add example.
{% endhint %}

### e\_mailout.php

This addon allows a plugin to use e107's mailout feature for bulk mailing.

{% hint style="info" %}
Please find an example in the "newsletter" plugin.&#x20;
{% endhint %}

### e\_menu.php

This addon provides configuration options for each instance of the plugin's menus.&#x20;

{% hint style="info" %}
The `e_menu.php` addon is a replacement for the old `config.php` file used in e107 v1.x.&#x20;
{% endhint %}

#### *Example:*

```php
class plugindir_menu // plugin-folder name + '_menu'
{
	function __construct()
	{
		
	}

	/**
	 * Configuration Fields. 
	 * See Admin-UI field configurations (https://devguide.e107.org/plugin-development/admin-ui)
	 * @return array
	 */
	public function config($menu='')
	{
		$fields = array();
		$fields['blankCaption'] 	= array('title' => "Caption", 'type' => 'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
		$fields['blankCount']		  = array('title' => "Enabled", 'type' => 'number');
		$fields['blankCustom']		= array('title' => "Enabled", 'type' => 'method'); // see below.

    return $fields;
	}
}

// optional - for when using custom methods above.
class plugindir_menu_form extends e_form
{
	function blankCustom($curVal)
	{
		$frm 	  = e107::getForm();
		$opts 	= array(1, 2, 3, 4);

		$frm->select('blankCustom', $opts, $curVal);
	}
}
```

### e\_meta.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_header.php](/plugin-development/extending-core-functionality-addons#e_header-php) instead.&#x20;
{% endhint %}

### e\_module.php

This addon is loaded every time the core of e107 is included. ie. Wherever you see `require_once("class2.php")` in a script.&#x20;

It allows a developer to modify or define constants, parameters etc. which should be loaded prior to the header or anything that is sent to the browser as output. It may also be included in Ajax calls.

### e\_notify.php

This addon adds the plugin to the :point\_right: [Notify](https://userguide.e107.org/administration/tools/notify) section in the Admin Area and allows a plugin to send notifications.&#x20;

#### *Example:*

```php
class plugindir_notify extends notify // plugin-folder name + '_notify' 
{		
	function config()
	{	
		$config = array();
	
		$config[] = array(
			'name'			=> "New Trigger Name", // Displayed in admin area. 
			'function'		=> "plugindir_mytrigger",
			'category'		=> ''
		);	
		
		return $config;
	}
	
	function plugindir_mytrigger($data) 
	{
		$message = print_a($data,true);
		
		$this->send('plugindir_mytrigger', "My Subject", $message);
	}
}
```

The notification can then be triggered by using:

```php
e107::getEvent()->trigger("plugindir_mytrigger", $data);
```

### e\_output.php

This addon allows to hook into all pages at the very end (after the closing `</html>`). This is useful for example when capturing :point\_right: [*output buffering*](https://www.php.net/manual/en/book.outcontrol.php)*.*

### e\_parse.php

This addon allows to hook into e107's [parser methods](/classes-and-methods/parser#parser-methods)

#### *Example:*

```php
class plugindir_parse // plugin-folder name + '_parse' 
{
	/**
	 * Process a string before it is sent to the browser as html.
	 * @param string $text html/text to be processed.
	 * @param string $context Current context ie.  OLDDEFAULT | BODY | TITLE | SUMMARY | DESCRIPTION | WYSIWYG etc.
	 * @return string
	 */
	function toHTML($text, $context = '')
	{
		$text = str_replace('****', '<hr>', $text);
		return $text;
	}


	/**
	 * Process a string before it is saved to the database.
	 * @param string $text html/text to be processed.
	 * @param array $param nostrip, noencode etc.
	 * @return string
	 */
	function toDB($text, $param = array())
	{
		$text = str_replace('<hr>', '****', $text);
		return $text;
	}
}
```

### e\_print.php

This addon allows a plugin developer to specify content that is displayed in printer-friendly format

#### ***Example:***

```php
class plugindir_print // plugin-folder + '_print'
{
	public function render($parm)
	{
		$text = "Hello {$parm}!"; 

		return $text;
	}	
}
```

### e\_rss.php

This addon adds the plugin to the RSS plugin, and generates RSS feeds for the plugin.

#### *Example:*

```php
class plugindir_rss // plugin-folder name + '_rss'
{
	/**
	 * Admin RSS Configuration
	 */
	function config()
	{
		$config = array();

		$config[] = array(
			'name'			  => 'Feed Name',
			'url'			    => 'blank',
			'topic_id'		=> '',
			'description'	=> 'This is the RSS feed for the blank plugin', // that's 'description' not 'text'
			'class'			  => e_UC_MEMBER,
			'limit'			  => '9'
		);

		return $config;
	}

	/**
	 * Compile RSS Data
	 * @param array $parms
	 * @param string $parms['url']
	 * @param int $parms['limit']
	 * @param int $parms['id']
	 * @return array
	 */
	function data($parms=array())
	{
		$sql = e107::getDb();

		$rss = array();
		$i = 0;

		if($items = $sql->select('blank', "*", "blank_field = 1 LIMIT 0,".$parms['limit']))
		{
			while($row = $sql->fetch())
			{
				$rss[$i]['author']			  = $row['blank_user_id'];
				$rss[$i]['author_email']	= $row['blank_user_email'];
				$rss[$i]['link']			    = "_blank/_blank.php?";
				$rss[$i]['linkid']			  = $row['blank_id'];
				$rss[$i]['title']			    = $row['blank_title'];
				$rss[$i]['description']		= $row['blank_message'];
				$rss[$i]['category_name']	= '';
				$rss[$i]['category_link']	= '';
				$rss[$i]['datestamp']		  = $row['blank_datestamp'];
				$rss[$i]['enc_url']			  = "";
				$rss[$i]['enc_leng']		  = "";
				$rss[$i]['enc_type']		  = "";
				$i++;
			}

		}

		return $rss;
	}
}
```

### e\_related.php

This addon adds the plugin to the search which generates 'related' links in news items and pages of e107.&#x20;

#### *Example:*

```php
class plugindir_related // plugin-folder name + '_menu'
{
	function compile($tags,$parm=array()) 
	{
		$sql 	= e107::getDb();
		$items 	= array();
			
		$tag_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'";
		
		$query = "SELECT * FROM `#_blank` WHERE _blank_id != ".$parm['current']." AND _blank_keywords REGEXP ".$tag_regexp."  ORDER BY _blank_datestamp DESC LIMIT ".$parm['limit'];
			
		if($sql->gen($query))
		{		
			while($row = $sql->fetch())
			{

				$items[] = array(
					'title'			=> varset($row['blank_title']),
					'url'			=> e107::url('other',$row),
					'summary'		=> varset($row['blank_summary']),
					'image'			=> '{e_PLUGIN}_blank/images/image.png'
				);
			}
			
			return $items;
	    }
	
	}
}
```

### e\_search.php

This addon adds the plugin to the 'search page' of e107.

#### *Example:*

```php
class plugindir_search extends e_search // plugin-folder name + '_search'
{
	function config()
	{	
		$search = array(
			'name'			=> "Blank Plugin",
			'table'			=> 'blank',

			'advanced' 		=> array(
								'date'	=> array('type'	=> 'date', 		'text' => LAN_DATE_POSTED),
								'author'=> array('type'	=> 'author',	'text' => LAN_SEARCH_61)
							),
							
			'return_fields'	=> array('blank_id', 'blank_nick', 'blank_message', 'blank_datestamp'),
			'search_fields'	=> array('blank_nick' => '1', 'blank_message' => '1'), // fields and weights.
			
			'order'			=> array('blank_datestamp' => 'DESC'),
			'refpage'		=> 'chat.php'
		);

		return $search;
	}

	/* Compile Database data for output */
	function compile($row)
	{
		preg_match("/([0-9]+)\.(.*)/", $row['blank_nick'], $user);

		$res = array();
	
		$res['link'] 		  = e_PLUGIN."blank_menu/_blank.php?".$row['blank_id'].".fs";
		$res['pre_title'] = LAN_SEARCH_7;
		$res['title'] 		= $user[2];
		$res['summary'] 	= $row['blank_message'];
		$res['detail'] 		= e107::getParser()->toDate($row['blank_datestamp'], "long");

		return $res;		
	}

	/**
	 * Optional - Advanced Where
	 * @param $parm - data returned from $_GET (ie. advanced fields included. in this case 'date' and 'author' )
	 */
	function where($parm=null)
	{
		$tp = e107::getParser();

		$qry = "";
		
		if (vartrue($parm['time']) && is_numeric($parm['time'])) 
		{
			$qry .= " blank_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND";
		}

		if (vartrue($parm['author'])) 
		{
			$qry .= " blank_nick LIKE '%".$tp->toDB($parm['author'])."%' AND";
		}
		
		return $qry;
	}
}
```

### e\_shortcode.php

This addon allows a plugin to make their shortcodes available to core templates and templates of other plugins.&#x20;

It's content is identical to that of a regular shortcode class except that all the methods must follow the following naming convention: `sc_plugindir_name()`

The `$override` property can be used to override existing core/plugin shortcodes. When set to true existing core/plugin shortcodes matching methods below will be overridden.&#x20;

#### *Example:*

```php
class plugindir_shortcodes extends e_shortcode
{
	public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden. 

	// Example: {PLUGINDIR_CUSTOM} shortcode - available site-wide.
	function sc_plugindir_custom($parm = null)  // Naming:  "sc_" + [plugin-directory] + '_uniquename'
	{
		return "Hello World!";
	}
}
```

### e\_sitelink.php

This addon adds a sitelink sublink-generating function for your plugin. An example is auto-generated navigation drop-down menus for 'latest articles'.&#x20;

#### *Example:*

```php
class plugindir_sitelink // plugin-folder name + '_sitelink' 
{
	function config()
	{
		$links = array();	
		
		$links[]  = array(
			'name'        => 'Drop-Down MegaMenu',
			'function'    => 'megaMenu' // see method below
		);

		$links[] = array(
			'name'			  => "Drop-Down Links",
			'function'		=> "myCategories" // see method below
		);
	
		return $links;
	}
	

	function megaMenu() 
	{
		$text = '<div class="dropdown-menu mega-dropdown-menu">
                    <div class="container-fluid2">
                            <ul class="nav-list list-inline">
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                                <li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
                            </ul>
                    </div>
				</div>			
				';

		return $text;
	}

	function myCategories()
	{
		$sublinks 	= array();
		
		e107::getDb()->select("blank","*","blank_id != '' ");
		
		while($row = e107::getDb()->fetch())
		{
			$sublinks[] = array(
				'link_name'			    => e107::getParser()->toHTML($row['blank_name'],'','TITLE'),
				'link_url'			    => e107::url('_blank', 'other', $row),
				'link_description'	=> '',
				'link_button'		    => $row['blank_icon'],
				'link_category'		  => '',
				'link_order'		    => '',
				'link_parent'		    => '',
				'link_open'			    => '',
				'link_class'		    => e_UC_PUBLIC
			);
		}
		
		return $sublinks;
	}
}
```

### e\_status.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_dashboard.php](/plugin-development/extending-core-functionality-addons#e_dashboard-php) instead.&#x20;
{% endhint %}

### e\_tohtml.php

{% hint style="warning" %}
**Deprecated!**\
This addon has been deprecated. Use [e\_parse.php](/plugin-development/extending-core-functionality-addons#e_parse-php) instead.&#x20;
{% endhint %}

### e\_upload.php

{% hint style="info" %}
**TODO:** Add example.
{% endhint %}

### e\_url.php

This addon provides a simple way to add mod-rewrite redirects to the plugin's pages, without having to edit the `.htaccess` file. This addon is used to create Search-Engine-Friendly (SEF) URLs through the [e107::url()](/classes-and-methods/urls) method.

#### *Example:*

{% hint style="info" %}
*TODO: add 'legacy' example and explanation*
{% endhint %}

{% hint style="info" %}
TODO: *e\_ROUTE -* <https://github.com/e107inc/e107/issues/3912>
{% endhint %}

```php
class plugindir_url // plugin-folder name + '_url' 
{
	function config() 
	{
		$config = array();

		$config['index'] = array(
			'regex'			  => '^_blank/?$', 						// matched against url, and if true, redirected to 'redirect' below.
			'sef'			    => '_blank', 							// used by e107::url(); to create a url from the db table.
			'redirect'		=> '{e_PLUGIN}_blank/blank.php', 		// file-path of what to load when the regex returns true.
		);

		$config['other'] = array(
			'alias'       => '_blank', 									// the below {alias} is substituted with this value. Default alias '_blank', w which can be customized within the admin area.
			'regex'			  => '^{alias}/other/?$', 						// matched against url, and if true, redirected to 'redirect' below.
			'sef'			    => '{alias}/other/', 							// used by e107::url(); to create a url from the db table.
			'redirect'		=> '{e_PLUGIN}_blank/_blank.php?other=1', 		// file-path of what to load when the regex returns true.
		);

		return $config;
	}
}
```

### e\_user.php

This addon allows to:

* add information about a specific user to the user's profile page
* add and save fields to the user configuration page (`/usersettings.php`)
* specify a routine that is run upon user deletion

#### *Example:*

```php
class plugindir_user // plugin-folder + '_user'
{		
	/**
	 * Display information on the user profile page 
	 */
	function profile($udata)  
	{

		$var = array(
			0 => array(
				'label' => "Label", 
				'text' 	=> "Some text to display", 
				'url'	  => e_PLUGIN_ABS."_blank/blank.php")
		);
		
		return $var;
	}

	/**
	 * This allows to show field on the usersettings.php page
	 * The same field format as admin-ui, with the addition of 'fieldType', 'read', 'write', 'appliable' and 'required' as used in extended fields table.
	 *
	 * @return array
	 */
	function settings()
	{
		$fields = array();

		$fields['field1'] = array(
			'title' 	   => "Field 1",  
			'fieldType'  => 'varchar(30)',  
			'read'		   => e_UC_ADMIN, 
			'write'		   => e_UC_MEMBER, 
			'type' 		   => 'text', 
			'writeParms' => array('size' => 'xxlarge')
		);

		$fields['field2'] = array(
			'title' 	   => "Field 2",  
			'fieldType'  => 'int(2)',       
			'type' 		   => 'number', 
			'data'		   => 'int'
		);

		$fields['field3'] = array(
			'title' 	  => "Field 3",  
			'fieldType' => 'int(1)',       
			'type' 		  => 'method', // see method below.
			'data'		  => 'str', 
			'required'	=> true
		); 

        return $fields;
	}

	/**
	 * This routine is run upon user deletion
	 * Experimental and subject to change without notice.
	 * @return mixed
	 */
	function delete()
	{

		$config['user'] =  array(
			'user_id'           => '[primary]',
			'user_name'         => '[unique]',
			'user_loginname'    => '[unique]',
			'user_email'        => '[unique]',
			'user_ip'           => '',
			// etc.
			'WHERE'             => 'user_id = '.USERID,
			'MODE'              => 'update'
		);

		$config['user_extended'] = array(
			'WHERE'             => 'user_extended_id = '.USERID,
			'MODE'              => 'delete'
		);

		return $config;
	}
}

// (plugin-folder)_user_form - only required when using custom methods.
class plugindir_user_form extends e_form
{
	// user_plugin_(plugin-folder)_(fieldname)
	public function user_plugin_plugindir_field3($curVal, $mode, $att = array())
	{
		$opts = array(1, 2, 3, 4);
		return $this->select('user_plugin_plugindir_field3', $opts, $curVal);
	}
}
```


# Upgrading legacy plugins

## Introduction

Back in September 2015, [e107 v2.0.0 was officially released](https://github.com/e107inc/e107/releases/tag/v2.0.0). Currently, any older version of e107 (such as version 1.0.4) is considered to be *Legacy,* and is also referred to as *e107 v1.x*.&#x20;

Plugins and themes developed for e107 v1.x will continue to work on v2.x. However, to get the most out of v2.x, it is strongly recommended for developers to make changes to their code and bring the code up to the new v2.x standards.

**This way, developers can:**&#x20;

* Ensure **continued functionality** of their plugins and themes in future versions of e107
* Benefit from major **performance and security enhancements**.&#x20;
* Benefit from all **new features and functionalities** that are being developed in v2.x.&#x20;

{% hint style="success" %}
:thumbsup: Even though a lot of effort has been put in retaining *backwards compatibility* with older versions of e107, developers are **strongly encouraged** to update their code to new standards.&#x20;
{% endhint %}

## PHP and MySQL versions

The functionality of plugins also depends on the PHP and MySQL versions that are being used.&#x20;

Plugins that are not regularly updated may make use of deprecated and/or removed PHP/MySQL functionality. In this case, plugins can cause a website to malfunction, or plugins appear to be broken.&#x20;

{% hint style="success" %}
**TIP:** When updating plugins, take into consideration the latest PHP/MySQL developments to ensure continued functionality.&#x20;
{% endhint %}

{% hint style="info" %}
Check the :point\_right: [requirements page](https://userguide.e107.org/installation-and-maintenance/requirements) for more information on the minimal and recommended requirements for an e107 installation.&#x20;
{% endhint %}

## Minimum and recommended changes

### Minimum Changes:

* Include a [plugin.xml](/plugin-development/installation-and-configuration#plugin-xml) file

### Recommended Changes:

* Include a [plugin.xml](/plugin-development/installation-and-configuration#plugin-xml) file
* Use e107's [Forms](/classes-and-methods/forms) class for all form elements.
* Use :point\_right: [Bootstrap HTML/CSS standards](https://getbootstrap.com/) in your templates and/or HTML markup
* Upgrade [e107 addons (e\_xxxx.php files)](/plugin-development/extending-core-functionality-addons) to v2.x standards
* Upgrade[ language-files](/plugin-development/internationalisation) to new standards

## Classes & methods

In e107 v2.x, numerous classes and methods were introduced in order to standardize functionality across installations, ensure continued functionality and to minimize performance issues and security risks.

{% hint style="success" %}
Developers are **strongly encouraged** to make use of e107's standard [classes & methods](/classes-and-methods/introduction)
{% endhint %}

{% content-ref url="/pages/-M8L6DV1j49qo4gy5d-V" %}
[Introduction](/classes-and-methods/introduction)
{% endcontent-ref %}

{% hint style="info" %}
TODO: Provide examples of legacy methods&#x20;
{% endhint %}

## Frontend

### HTML & CSS

e107 v2.x follows the [bootstrap standard](https://getbootstrap.com/) for [CSS](/classes-and-methods/css). Some examples:

* `<input class='button'` should become `<input class='btn button'`
* `<table class='fborder'` should become `<table class='table fborder'`
* `<table>` which use the class `'fcaption'` on `<td>` should change the `<td>` to `<th>`.&#x20;
* Using the `forumheader3` class in the *Admin Area* is obsolete and can be removed.&#x20;

### Templates

{% hint style="info" %}
:thumbsup: **TIP**: Read more about [templates & shortcodes ](/templates-shortcodes-and-constants/introduction)
{% endhint %}

#### Loading Templates

e107 v2.x uses a new template loading system.&#x20;

Plugin templates should be stored in [*e107\_plugins*](/getting-started/folder-structure)*/yourplugin/templates/* by default. The template file should contain a variable with the same name as your template file. Instead of including the template, below is the difference:

```php
// e107 v1.x and older
require_once(e_PLUGIN."myplugin/templates/myplugin_template.php"); // v1.x

// from e107 v2.x onwards
$MYPLUGIN_TEMPLATE = e107::getTemplate('myplugin');
```

..and then you can parse it the same way:

```php
$text = $tp->parseTemplate($MYPLUGIN_TEMPLATE['start'], false, $my_shortcodes);
```

{% hint style="info" %}
:thumbsup: **TIP**: Read more about the [parsing methods](/classes-and-methods/parser)
{% endhint %}

#### Declaring the HTML Template

eg. If your file is called **myplugin\_template.php** , within this file you might see something like this:

```php
$MYPLUGIN_TEMPLATE['start'] = "<div>";
$MYPLUGIN_TEMPLATE['end'] = "</div>";
```

#### Shortcode Wrappers.

In v2.x there are two methods to add wrappers around your shortcodes. The way to declare them differs slightly from v1 in that we use a kind of 'shortcode-wildcard' `{---}`.

{% hint style="info" %}
:thumbsup: **TIP**: Read more about [shortcodes](/templates-shortcodes-and-constants/core-shortcodes)
{% endhint %}

{% content-ref url="/pages/-M8QB9q0lgI521XAHMwa" %}
[Core Shortcodes](/templates-shortcodes-and-constants/core-shortcodes)
{% endcontent-ref %}

{% content-ref url="/pages/-MUSud-U6Tf7N7IjHrR3" %}
[Shortcodes](/templates-shortcodes-and-constants/shortcodes)
{% endcontent-ref %}

#### **Global Shortcodes**

A global shortcode wrapper. ie for shortcodes which are available site-wide. (for example those registered globally for use in menus or found in e107\_core/shortcodes/single/)&#x20;

**Example:**

```php
// v1.x way of doing it. 
$sc_style['CONTACT_PERSON']['pre'] = "<small>".LANCONTACT_14."</small><div>";
$sc_style['CONTACT_PERSON']['post'] = "</div>";

// v2.x way of doing it. 
$SC_WRAPPER['CONTACT_PERSON']= "<small>".LANCONTACT_14."</small><div>{---}</div>";
```

#### **Template-Specific Shortcodes**

v2.x introduces a template-specific shortcode wrapper. ie. as used on a single page of your site. \
\
**Example:**

```php
$CONTACT_WRAPPER['form']['CONTACT_PERSON'] = "<small>".LANCONTACT_14."</small><div>{---}</div>";
```

## Admin Area

In e107 v2.x, the Admin Area uses a special admin "handler", the [Admin User Interface (Admin-UI)](https://devguide.e107.org/plugin-development/admin-ui).

In the Plugin Manager you will find something called "[Plugin Builder](/plugin-development/plugin-builder)". It allows you to select your e107 [`*_sql`](https://devguide.e107.org/plugin-development/installation-and-configuration#plugin_sql-php) file from your plugin folder and will generate most of the new code for the Admin Area of your plugin. It will also generate the new[ plugin.xml](https://devguide.e107.org/plugin-development/installation-and-configuration#plugin-xml) meta-file, which is used during [installation](/plugin-development/installation-and-configuration) of your plugin.

{% hint style="success" %}
:thumbsup: It is **strongly recommended** for plugin developers to upgrade their Admin Area using the [**Plugin Builder**](/plugin-development/plugin-builder)**.**
{% endhint %}

{% content-ref url="/pages/-M8L7UlhkmSR6OQuNPAr" %}
[Plugin Builder](/plugin-development/plugin-builder)
{% endcontent-ref %}

## Migrating plugin preferences

{% hint style="success" %}
:thumbsup: In e107 v.2x, it is **strongly recommended** for plugins to save their preferences in their own table row. Older plugins may still store plugin preferences in the [`core`](/getting-started/database-structure#database-tables-overview) preference table.
{% endhint %}

### migrateData()

To easily migrate from one to the other, one can use the method called `migrateData()`.

#### Example of migrating plugin preferences to their own row in the database:

```php
$oldPluginPrefs = array(
    'myplugin_caption' => 'caption', // old-pref-name => new-pref-name 
    'myplugin_display' => 'display',
    'myplugin_maxage'  => 'maxage',
);

if($newPrefs = e107::getConfig()->migrateData($oldPluginPrefs,true)) // returns new array with values and deletes core pref. 
{
    $result = e107::getPlugConfig('myplugin')->setPref($newPrefs)->save(false,true,false); // save new prefs to 'myplugin'. 
}
```


# Introduction

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

{% hint style="info" %}
TODO:

* Overview of folder structure with files
* Note on upgrading v1 to v2 themes (legacy) - link to upgrading
* Note on styling (bootstrap)
  {% endhint %}


# Installation & configuration

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

{% hint style="info" %}
TODO:

* overview of install & config files (theme.xml & theme\_config.php)
* highlight some options
* refer to example themes (bootstrap3)
  {% endhint %}

## theme.xml

This file contains information about the theme. and is used during installation and also during configuration of the theme.

{% hint style="success" %}
:thumbsup: **TIP:** To create a new `theme.xml` file or derive one from an existing v1.x `theme.php` file use the [conversion tool](https://userguide.e107.org/administration/manage/theme-manager#tools) in the Admin Area > Theme Manager > Tools \
(`/e107_admin/theme.php?mode=convert`)
{% endhint %}

{% hint style="info" %}
**Please note:** Unlike [plugin.xml](/plugin-development/installation-and-configuration#plugin-xml), the theme.xml file is not intended to replace the [theme.php](/theme-development/layout-and-templates#theme-php) file. Instead, theme.xml works alongside [theme.php](/theme-development/layout-and-templates#theme-php) to provide (meta)data about the theme itself.
{% endhint %}

### Example#1: Full theme.xml

The below example uses the theme.xml from the *Bootstrap3* theme included in e107 by default. Each section of the XML file is elaborated upon below.&#x20;

```markup
<?xml version="1.0" encoding="utf-8"?>
<e107Theme name="Bootstrap 3" version="1.0" date="2013-12-25" compatibility="2.0">
	<author name="e107 Inc" email="e107inc@something.com" url="http://e107.org" />
	<summary>Bootstrap3 e107 theme</summary>
	<description>a simple bootstrap 3 template for the frontend</description>
	<category>generic</category>
	<plugins>
		<plugin name='featurebox' url='core' />
		<plugin name='gallery' url='core' />
        <plugin name='rss_menu' url='core' />
        <plugin name='tinymce4' url='core' />
		<plugin name='social' url='core' />
	</plugins>
	<keywords>
		<word>bootstrap</word>
		<word>clean</word>
	</keywords>
	<screenshots>
		<image>preview_frontend.png</image>
	</screenshots>
	<libraries>
		<library name="bootstrap" version="3" scope="front,admin,wysiwyg"/>
		<library name="fontawesome" version="5"  scope="front,admin,wysiwyg"/>
		<library name="bootstrap.editable" scope="admin"/>
	</libraries>
	<stylesheets>
		<css file="style.css" name="Default" scope="front" />
		<css file="css/modern-light.css" name="Modern Light" description="A high-contrast light skin" thumbnail='images/admin_modern-light.webp' scope='admin' exclude='bootstrap'/>
	</stylesheets>
	<layouts>
		<layout name='jumbotron_home' title='Jumbotron (home)' default='false'>
			<custompages>FRONTPAGE</custompages>	
		</layout>
		<layout name='modern_business_home' title='Modern Business: Home page carousel with fixed custom-menus' />
		<layout name='jumbotron_full' title='Jumbotron (full-width)'  >
      <custompages>forum</custompages>
		</layout>
		<layout name='jumbotron_sidebar_right' title='Jumbotron (sidebar-right)' default='true' >
			<custompages>/news</custompages>
			<menuPresets>
				<area id='1'>
					<menu name='search' />
					<menu name='news_categories' />
					<menu name='other_news' />
					<menu name='other_news2' />
					<menu name='blogcalendar' />
				</area>
			</menuPresets>	
		</layout>
	</layouts>
	<themePrefs>
		<pref name='branding'>sitename</pref>
		<pref name='nav_alignment'>right</pref>
		<pref name='usernav_placement'>top</pref>
	</themePrefs>
</e107Theme>
```

### Example #2: Minimal theme.xml

{% hint style="info" %}
TODO: Provide minimal required theme.xml example
{% endhint %}

### e107Theme

This is the *namespace* the configuration lives in. All theme.xml files must begin and end with this tag.

```markup
<e107Theme name="" version="3.0" date="2012-01-07" compatibility="2.0">
... all content belongs here ...
</e107Theme>
```

The following attributes of the theme are defined here:

| Attribute         | Description                                                                                                                                                                                                                                                                                                                                                                                                    | Example                                                                                      | Mandatory? |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------- |
| **name**          | The name of your theme. This can be text or a constant defined from your themes's language file.                                                                                                                                                                                                                                                                                                               | Bootstrap3                                                                                   | **Yes**    |
| **version**       | <p>The version of the theme</p><p>(semantic versioning)</p>                                                                                                                                                                                                                                                                                                                                                    | 3.0                                                                                          | **Yes**    |
| **date**          | The date when the theme was released (latest version). (yyyy-mm-dd)                                                                                                                                                                                                                                                                                                                                            | 2020-30-12                                                                                   | **Yes**    |
| **compatibility** | <p>The minimum version of e107 required to use the theme.</p><p>(semantic versioning)</p>                                                                                                                                                                                                                                                                                                                      | 2.1.0                                                                                        | **Yes**    |
| price             | <p>In case of a commercial theme: the sales price of the theme. </p><p>(xx.xx format)</p>                                                                                                                                                                                                                                                                                                                      | 25                                                                                           | No         |
| currency          | In case of a commercial theme: the abbreviation of the currency in which the theme is sold for (see price).                                                                                                                                                                                                                                                                                                    | EUR                                                                                          | No         |
| url               | <p>In case of a commercial theme: the direct URL to the specific theme. </p><p></p><p>When the user clicks to download your theme, the URL you have provided will be loaded. </p><p></p><p><span data-gb-custom-inline data-tag="emoji" data-code="2757">❗</span><em>Note: do not add the URL to the generic homepage of your website, but only the URL to the specific page for that specific theme.</em></p> | [https://direct-path-to-purchase-page.com](http://direct-path-to-my-theme-purchase-page.com) | No         |

{% hint style="success" %}
&#x20;:thumbsup: **Tip:** If you are developing a **commercial theme**, you'll want to add a few extra attributes so that it displays correctly in the admin area under "[Find Themes](https://userguide.e107.org/administration/manage/theme-manager#find-themes)". \
\
Just package the theme's zip file with only the [theme.xml](/theme-development/installation-and-configuration#theme-xml) and any images (including screenshots), excluding .php, .css files etc. before sharing it in the :point\_right: [developers area on e107.org](https://e107.org/developers).\
\
When the user clicks to download the theme, it will display the **URL** you have provided.
{% endhint %}

{% hint style="info" %}
In previous versions of e107, the attribute `releaseUrl` was used. This attribute is deprecated and should be removed.&#x20;
{% endhint %}

### Author

Identifies the theme author and highlights some information. &#x20;

```markup
<author name="e107 Inc" email="e107inc@something.com" url="https//e107.org" />
```

:thumbsup: *Note the `/` to close the tag at the end.*&#x20;

The following attributes of the author are defined here:

| Attribute   | Description                                                                                                                                                                                                           | Example                             | Mandatory? |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ---------- |
| **name**    | The author's name, e107 user name or nickname.                                                                                                                                                                        | e107 Inc.                           | **Yes**    |
| **email**   | E-mail address. Useful to get feedback and bug reports on the theme. A *mailto* link to it is displayed on the *Admin Area >* [*Theme Manager*](https://userguide.e107.org/administration/manage/theme-manager) page. | <e107inc@something.com>             | **Yes**    |
| url         | A link to the author's website. A link to it is displayed on the *Admin Area >* [*Theme Manager*](https://userguide.e107.org/administration/manage/theme-manager) page.                                               | <https://www.e107.org>              | Yes        |
| description | A brief description of your theme. Displayed on the *Admin Area >* [*Theme Manager*](https://userguide.e107.org/administration/manage/theme-manager) page.                                                            | Example description of your choice. | No         |

### Summary

A text that shortly summarises the theme.&#x20;

```markup
<summary>Bootstrap3 e107 theme</summary>
```

{% hint style="info" %}
TODO: Check if using LAN is possible
{% endhint %}

### Description

A text that provides a more elaborate description of the theme.&#x20;

```markup
<description>a simple bootstrap 3 template for the frontend</description>
```

{% hint style="info" %}
TODO: Check if using LAN is possible.&#x20;
{% endhint %}

### Category

```markup
<category>generic</category>
```

The category that a theme belongs to. Possible values are:

* Generic&#x20;
* Adult&#x20;
* Blog&#x20;
* Corporate&#x20;
* Gaming&#x20;
* News

### Plugins

In this section, theme designers can include plugins that they intend to be used with the theme. In the :point\_right: "[Theme Manager](https://userguide.e107.org/administration/manage/theme-manager)" > [Site Theme](https://userguide.e107.org/administration/manage/theme-manager#site-theme) >  "[Suggested Plugin](https://userguide.e107.org/administration/manage/theme-manager#suggested-plugins)" section with buttons for those plugins that the user can click on to install them.&#x20;

```markup
<plugins>
    ...
</plugins>
```

#### plugin

```markup
<plugins>
		<plugin name='featurebox' url='core' />
</plugins>
```

| Attribute | Description                                                                                               | Example    | Mandatory? |
| --------- | --------------------------------------------------------------------------------------------------------- | ---------- | ---------- |
| **name**  | Refers to the plugin folder name of the recommended plugin.                                               | featurebox | **Yes**    |
| **url**   | <p>For plugins that are included in e107 by default, use "core". </p><p>For third-party plugins .... </p> | core       | **Yes**    |

{% hint style="info" %}
TODO: check format for third-party plugins.&#x20;
{% endhint %}

### Keywords

The keywords associated with the theme. They are used when searching for plugins either through the Admin Area or on :point\_right: <https://www.e107.org/themes>.&#x20;

```markup
<keywords>
		...
</keywords>
```

#### word

```markup
	<keywords>
		<word>bootstrap</word>
	</keywords>
```

### Screenshots

Each theme can contain one or more screenshots. These screenshots are displayed in the Admin Area and on :point\_right: <https://www.e107.org/themes>.&#x20;

```markup
	<screenshots>
		...
	</screenshots>
```

#### image

Refers to the location of the image file, relative to the root of the theme folder

```markup
	<screenshots>
		<image>preview_frontend.png</image>
	</screenshots>
```

### Libraries

{% hint style="info" %}
TODO: provide explanation
{% endhint %}

```markup
<libraries>
		<library name="bootstrap" version="3" scope="front,admin,wysiwyg"/>
		<library name="fontawesome" version="5"  scope="front,admin,wysiwyg"/>
		<library name="bootstrap.editable" scope="admin"/>
</libraries>
```

#### library

```markup
<libraries>
		<library name="fontawesome" version="5"  scope="front,admin,wysiwyg"/>
</libraries>
```

| **A**ttribute | Description                                                                                                                                                                | Example            | Mandatory? |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ---------- |
| **name**      | Name of the library                                                                                                                                                        | bootstrap.editable | **Yes**    |
| version       | <p>Version of the library. <br>(semantic versioning)</p>                                                                                                                   | 3                  | No         |
| **scope**     | <p>The area in which the library is included.<br><br>Possible values:</p><ul><li>front</li><li>admin</li><li>wysiwyg</li></ul><p>Can be multiple if separated by comma</p> | admin              | **Yes**    |

### Stylesheets

```markup
	<stylesheets>
		...
	</stylesheets>
```

#### css

```markup
<css file="css/modern-light.css" name="Modern Light" description="A high-contrast light skin" thumbnail='images/admin_modern-light.webp' scope='admin' exclude='bootstrap'/>
```

| **A**ttribute | Description | Example                         | Mandatory? |
| ------------- | ----------- | ------------------------------- | ---------- |
| **file**      |             | css/modern-light.css            | **Yes**    |
| **name**      |             | Modern Light                    | **Yes**    |
| description   |             | A high-contrast light skin      | No         |
| thumbnail     |             | images/admin\_modern-light.webp | No         |
| **scope**     |             | admin                           | **Yes**    |
| exclude       |             | bootstrap                       | No         |

{% hint style="info" %}
TODO: asterix (\*) usage?
{% endhint %}

### Layouts

```markup
<layouts>
    ...
</layouts>
```

Each theme can contain various layouts. Additionally, each layout can be used for specific[ custom pages](/theme-development/installation-and-configuration#custom-pages) and each layout can have specific [menu presets](/theme-development/installation-and-configuration#menu-presets).

#### Layout

```markup
<layout name='modern_business_home' title='Modern Business: Home page carousel with fixed custom-menus' />
```

| Attribute   | Description                                                                                                                                             | Example                                    | Mandatory? |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ---------- |
| **name**    | <p>Shortname of the layout</p><p>(use underscores)</p>                                                                                                  | jumbotron\_home                            | **Yes**    |
| **title**   | Descriptive title of the layout                                                                                                                         | Home page carousel with fixed custom-menus | **Yes**    |
| default     | <p>Indicates whether a layout is the default layout to be used. There can only be one default layout. </p><p><em>Boolean - defaults to 'false'</em></p> | true                                       | No         |
| preview     | <p>A preview image (thumbnail) of the layout. </p><p>(recommended dimensions?)</p>                                                                      | preview\.png                               | No         |
| previewFull | <p>A preview image of the layout (full size)</p><p>(recommended dimensions?)</p>                                                                        | preview\_full.png                          | No         |

#### Custom Pages

Each layout can assign specific pages which then, by default, make use of this specific layout. The user can modify the pages used by each layout in the :point\_right: "[Theme Manager](https://userguide.e107.org/administration/manage/theme-manager)" > [Site Theme](https://userguide.e107.org/administration/manage/theme-manager#site-theme) >  > [Layouts section](https://userguide.e107.org/administration/manage/theme-manager#layouts)

```markup
<layouts>
		<layout name='jumbotron_home' title='Jumbotron (home)' default='false'>
			<custompages>FRONTPAGE</custompages>	
		</layout>
</layouts>
```

{% hint style="success" %}
:thumbsup: You can use the constant `FRONTPAGE` to refer to the currently set :point\_right: [frontpage](https://userguide.e107.org/administration/settings/front-page) setting.&#x20;
{% endhint %}

[Using the e\_ROUTE](/classes-and-methods/urls#using-e_route) constant

{% hint style="warning" %}
Adding `$CUSTOMPAGES` to [theme.php](/theme-development/layout-and-templates#theme-php) in e107 v2.x is deprecated and should be avoided!
{% endhint %}

#### Menu Presets

Theme authors can create buttons for menus that can be activated by the user from "Menu Manager" or "Theme Manager". These are placed between  and and should be enclosed in the  and tags with the opening area tag naming the menu area it corresponds to; the example below would be for a layout with two (2) menu areas ({MENU=1} =  and {MENU=2} = ). The tag "menu name" must contain the name of a valid and installed menu.

### ThemePrefs

Set default theme preferences?

TODO: also refer to [theme\_config.php](/theme-development/installation-and-configuration#theme_config-php)

#### pref

name, (value)

## theme\_config.php

This file can be used to add information and user-selectable options to the theme's configuration page.&#x20;

{% hint style="success" %}
:thumbsup: If you want users to b e able to set specific theme preferences, use the theme\_config.php file.&#x20;
{% endhint %}

#### Example

```php
class theme_mytheme implements e_theme_config
{
    function process() // Save posted values from config() fields. 
    {
        $pref = e107::getConfig();
		
        $theme_pref 					  = array();
        $theme_pref['example']	= $_POST['_blank_example'];
        $theme_pref['example2']	= intval($_POST['_blank_example2']);

        $pref->set('sitetheme_pref', $theme_pref);
        return $pref->dataHasChanged();
    }

    function config()
    {
        $tp = e107::getParser();
		
        $var[0]['caption'] = "Sample configuration field";
        $var[0]['html']    = $tp->text('_blank_example', e107::getThemePref('example', 'default'));

        $var[1]['caption'] = "Sample configuration field";
        $var[1]['html']    = $tp->text('_blank_example2', e107::getThemePref('example2', 'default'));
		
        return $var;
    }

    function help()
    {
        return "
                <div class='well'>
                        Some information about my theme. 
                </div>
        ";
    }
}
```

## Favicon

Automatically, e107 is looking for the **favicon.ico** file in the following locatons in this **specific** **order**:&#x20;

1. inside the root of the theme folder (`e107_themes/yourtheme`)&#x20;
2. inside the root of the e107 installation (`/`)

This way, theme authors can override the default *favicon*, and users can upload their own *favicon* to the theme folder.&#x20;

{% hint style="success" %}
:thumbsup: **TIP:** To insert more favicons, you can use the :point\_right: [Meta Tags](https://userguide.e107.org/administration/settings/meta-tags)
{% endhint %}


# Layout & templates

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet
{% endhint %}

## Introduction

## theme.php&#x20;

{% hint style="warning" %}
Adding `$CUSTOMPAGES` to [theme.php](/theme-development/layout-and-templates#theme-php) in e107 v2.x is deprecated and should be avoided!
{% endhint %}

## theme.html


# Theme Shortcodes

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

......

## Common theme shortcodes

{% hint style="info" %}
Please refer the the [Theme shortcodes](/templates-shortcodes-and-constants/core-shortcodes#theme-shortcodes) section&#x20;
{% endhint %}

## theme\_shortcodes.php

{% hint style="success" %}
:thumbsup: **TIP:** As of e107 v2.x, you no longer need separate `xxxxxx.sc` files inside your theme's folder. You can now include all your theme-specific shortcodes in a single file called [**theme\_shortcodes.php**](/theme-development/theme-shortcodes#theme_shortcodes-php).&#x20;
{% endhint %}

These shortcodes may be used in your **theme.html** and **layout/xxx \_layout.html** files which reside inside your theme's folder. eg. Using the example below: `{MY_SHORTCODE}` and `{MY_OTHER_SHORTCODE}` will be substituted with "Something" and "Something else".

```php
class theme_shortcodes extends e_shortcode
{
	
    function sc_my_shortcode()
    {
        return "Something";
    }

    function sc_my_other_shortcode()
    {
        return "Something else";
    }

}
```


# Styling (CSS)

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

* e107 v2.x is designed for Bootstrap styling. It is therefore encouraged for developers to use bootstrap as their guide for their HTML markup.
* A default Bootstrap 3 is provided with e107. For html markup and examples, please refer to the [Bootstrap documentation](http://getbootstrap.com/css/) and for snippets: [bootsnipp.com](http://bootsnipp.com/).
* If you find markup in the core templates of e107 which does not work well with bootstrap, please let us know in the Github issue tracker, so that we may correct it.

## style.css


# Upgrading legacy themes

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

Themes developed for v1.x of e107 will continue to work using v2.x. However, to get the most out of v2.x, it is recommended to make the following changes to bring your theme up to date with the new v2.x standards.

## theme.php

* Replace **$HEADER** and **$FOOTER** with **$HEADER\['default']** and **$FOOTER\['default']**
* Replace any occurrences of **$CUSTOMHEADER** and **$CUSTOMFOOTER** with **$HEADER\['custom']** and **$FOOTER\['custom']**
* If your theme contains links to external social media pages such as Facebook, Twitter or YouTube, use the core definitions for them. ie. **XURL\_FACEBOOK**, **XURL\_TWITTER**, **XURL\_YOUTUBE.**&#x20;
* Remove any reference to **$CUSTOMPAGES** and place them inside [**theme.xml**](/theme-development/installation-and-configuration#theme-xml) in the [layouts](/theme-development/installation-and-configuration#layout-section) section.&#x20;

```markup
<layout name='custom' title='Custom Pages'>
	<custompages>FRONTPAGE</custompages>
	<custompages>/forum/</custompages>
</layout>
```

* If you have used index.php in your **$CUSTOMPAGES** list, use **FRONTPAGE** instead (see above)
* The function **theme\_head()** has been deprecated. Instead, use either [e107::css()](/classes-and-methods/css) or [e107::js()](/classes-and-methods/javascript) to include what you require in the header. (see bootstrap or other new core theme for examples)
* **Shortcodes** need to be set to **UPPERCASE** in all occurrences in your [theme.php](/theme-development/layout-and-templates#theme-php) file. (`$register[]` and everywhere else in [theme.php](/theme-development/layout-and-templates#theme-php))

## Theme shortcodes

{% hint style="info" %}
**TIP:** As of e107 v2.x, you no longer need separate `xxxxxx.sc` files inside your theme's folder. You can now include all your theme-specific shortcodes in a single file called[**`theme_shortcodes.php`**](/theme-development/theme-shortcodes#theme_shortcodes-php).&#x20;
{% endhint %}

Read more on theme shortcodes here:

{% content-ref url="/pages/-MUSuibkooxVi6EbjZsQ" %}
[Theme Shortcodes](/theme-development/theme-shortcodes)
{% endcontent-ref %}


# Introduction

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}


# Templates

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

* Templates and shortcodes function together to allow a developer to place dynamic content into their code.
* Templates are portions of HTML which contain *markers* that are replaced by dynamic content when parsed e107's `parseTemplate()`function.
* These *markers* are called 'shortcodes'.
* A shortcode is always CAPITALIZED and is surrounded by curly brackets and it may contain letters and underscores. For example: `{MY_SHORTCODE}`
* Each shortcode has a corresponding function/method which is run during the parsing of the template. These functions are always lowercase and begin with the prefix `sc_` . eg. `sc_my_shortcode()`. This means that `{MY_SHORTCODE}` is replaced by what is returned by `sc_my_shortcode()`.
* Shortcodes may also contain parameters which are sent to the corresponding method. For example: `{MY_SHORTCODE: x=foo&y=bar}`

## Creating templates

Create a folder called `templates` inside your plugin directory, and inside create an empty file using the name of your plugin folder, followed by `_template.php`. eg. `myplugin_template.php` Inside this file add an array by the same name, but in UPPERCASE: eg. `$MYPLUGIN_TEMPLATE['xxxx']` `xxxx` can be anything you want, but we suggest using `start`, `item`, `end` etc. when applicable. This value should always be lowercase. Here's a simple example of the contents of `myplugin_template.php`:

```php
<?php

$MYPLUGIN_TEMPLATE['start'] = "<ul>";
$MYPLUGIN_TEMPLATE['item'] = "<li>{MYPLUGIN_ITEM}</li>";
$MYPLUGIN_TEMPLATE['end'] = "</ul>";

?>
```

If your plugin will use several different types of templates, eg. a listing page and an input form. You can do something like this:

```php
<?php

$MYPLUGIN_TEMPLATE['list']['start'] = "<ul>";
$MYPLUGIN_TEMPLATE['list']['item'] = "<li>{MYPLUGIN_ITEM}</li>";
$MYPLUGIN_TEMPLATE['list']['end'] = "</ul>";

$MYPLUGIN_TEMPLATE['form']['start'] = "<form>";
$MYPLUGIN_TEMPLATE['form']['body'] = "<div>{MYPLUGIN_FORMINPUT}</divi>";
$MYPLUGIN_TEMPLATE['form']['end'] = "</form>";

?>
```

## Loading templates

&#x20;You may load a template file in the following way:

```
$template   = e107::getTemplate('myplugin'); // loads e107_plugins/myplugin/templates/myplugin_template.php
```

\
You can now use the `$template` code array for parsing:

```php
$text = e107::getParser()->parseTemplate($template['start'], true, $scObj);

// or

$text = e107::getParser()->parseTemplate($template['form']['start'], true, $scObj);

```

## Overriding Core Templates

* All templates that are used in e107 can be overridden by copying them into specific folders within your current theme folder.&#x20;
* Core themes (located in `e107_core/templates/` ) should be copied into `e107_themes/YOURTHEME/templates/`&#x20;
* Plugin templates should be copied into `e107_themes/YOURTHEME/templates/PLUGIN-FOLDER`\
  Note: Older plugins may look for templates in the root folder of your theme. ie. `e107_theme/YOURTHEME/` &#x20;

### *Examples*

1\) The comment template is a core template, as it is located in e107\_core/templates/. To override this template, copy the file to e107\_themes/your\_theme\_folder/templates/.\
\
2\) The news template is located in e107\_plugins/news/. To override this template, copy the file over to e107\_themes/your\_theme\_folder/templates/news/.\
\
3\) The same for, for example, the chatbox menu template. The chatbox\_menu template is located in e107\_plugins/chatbox\_menu. Copy the template over to e107\_themes/your\_theme\_folder/templates/chatbox\_menu/

**Important:** For overriding plugin templates, the folder name within your\_theme\_folder/templates/ directory must match the **exact** plugin folder name.


# Shortcodes

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

Theme shortcodes&#x20;

Plugin shortcodes


# Core Shortcodes

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Theme shortcodes

| Shortcode             | Description                                                                                                                                                                     |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{---}`               | Renders the main content of the current page.                                                                                                                                   |
| `{CMENU=xxxxxx}`      | Renders a specific custom menu item as defined in admin -> Pages/Menus. xxxxxx = menu name.                                                                                     |
| `{LOGO}`              | The site's logo as defined in the admin preferences.                                                                                                                            |
| `{MENU=1}`            | Menu Area as allocated using the media-manager in admin. Add multiple areas by incrementing the numeric value.                                                                  |
| `{MENU: type=xxxxxx}` | When `xxxxxx` is NOT a number, it will attempt to render a specific menu with the name `xxxxxx`. eg. `{MENU=contact}` will render `e107_plugins/contact/contact_menu.php`       |
| `{NAVIGATION=xxxxx}`  | Bootstrap-style navigation. Where `xxxxx` is one of: main, side, footer, alt, alt5, alt6 eg. `{NAVIGATION=footer}`                                                              |
| `{SETSTYLE=xxxxxx}`   | A special shortcode which is used to dynamically change the value of `$style` as used inside [tablerender()](/classes-and-methods/render#tablerender) to the value of `xxxxxx`. |
| `{SETIMAGE: w=x}`     | A special shortcode which is used to dynamically change the size of avatars and other images. x= numerical value. eg. `{SETIMAGE: w=100&h=200&crop=1}`                          |
| `{SITEDESCRIPTION}`   | The description of the website as defined in the admin preferences.                                                                                                             |
| `{SITEDISCLAIMER}`    | The site disclaimer as defined in the admin preferences. Typically used in the footer of the site.                                                                              |
| `{SITENAME}`          | The name of the website as defined in the admin preferences.                                                                                                                    |
| `{WMESSAGE}`          | Renders the welcome message as defined in admin-> Welcome Message.                                                                                                              |

## Page / Menu Shortcodes

| Shortcode               | Description                   | Optional Parameters                                   |
| ----------------------- | ----------------------------- | ----------------------------------------------------- |
| `{CPAGEANCHOR}`         |                               |                                                       |
| `{CPAGETITLE}`          | Title of the page             |                                                       |
| `{CPAGEBODY}`           | Main text body of the page    |                                                       |
| `{CPAGEAUTHOR}`         | Author of the page            |                                                       |
| `{CPAGEDATE}`           | Creation date of the page     | `{CPAGEDATE=x}` default: long. 'short' and 'relative' |
| `{CPAGEMETADIZ}`        | Meta description of the page. |                                                       |
| `{CPAGEBUTTON}`         |                               |                                                       |
| `{BOOK_ANCHOR}`         |                               |                                                       |
| `{BOOK_DESCRIPTION}`    |                               |                                                       |
| `{BOOK_ICON}`           |                               |                                                       |
| `{BOOK_ID}`             |                               |                                                       |
| `{BOOK_NAME}`           |                               |                                                       |
| `{BOOK_URL}`            |                               |                                                       |
| `{CHAPTER_ANCHOR}`      |                               |                                                       |
| `{CHAPTER_BREADCRUMB}`  |                               |                                                       |
| `{CHAPTER_BUTTON}`      |                               |                                                       |
| `{CHAPTER_DESCRIPTION}` |                               |                                                       |
| `{CHAPTER_ICON}`        |                               |                                                       |
| `{CHAPTER_ID}`          |                               |                                                       |
| `{CHAPTER_NAME}`        |                               |                                                       |
| `{CHAPTER_URL}`         |                               |                                                       |

## News Shortcodes

| Shortcode                     | Description                                                                    | Optional Parameters |                                             |
| ----------------------------- | ------------------------------------------------------------------------------ | ------------------- | ------------------------------------------- |
| `{NEWS_ID}`                   | Unique ID for the current news item (news\_id)                                 |                     |                                             |
| `{NEWS_TITLE}`                | News Title                                                                     |                     |                                             |
| `{NEWS_SUMMARY}`              | News item summary                                                              |                     |                                             |
| `{NEWS_DATE}`                 | News Date                                                                      |                     |                                             |
| `{NEWS_BODY}`                 | News Body (main content)                                                       |                     |                                             |
| `{NEWS_TAGS}`                 | New Keywords/Meta-Keywords                                                     |                     |                                             |
| `{NEWS_URL}`                  | News URL (current URL)                                                         |                     |                                             |
| `{NEWS_AUTHOR}`               | Name of the Author of the news item                                            |                     |                                             |
| `{NEWS_AUTHOR_AVATAR}`        | Avatar of the Author of the news item                                          |                     |                                             |
| `{NEWS_AUTHOR_SIGNATURE}`     | Signature text of the Author of the news item. eg. a short bio about the user. |                     |                                             |
| `{NEWS_AUTHOR_ITEMS_URL}`     | Link to a News page listing all items by the same author.                      |                     |                                             |
|                               |                                                                                |                     |                                             |
| `{NEWS_CATEGORY_NAME}`        | News Category Name                                                             |                     |                                             |
| `{NEWS_CATEGORY_DESCRIPTION}` | News Category Description                                                      |                     |                                             |
| `{NEWS_CATEGORY_ICON}`        | News Category Icon                                                             |                     |                                             |
|                               |                                                                                |                     |                                             |
| `{NEWS_RELATED}`              | Related news items based on keyword matches                                    | <p>types: news      | page<br>limit: (integer) (default is 5)</p> |
|                               |                                                                                |                     |                                             |

## Directory & path Shortcodes

| Shortcode         | Description | Default value |
| ----------------- | ----------- | ------------- |
| `{e_MEDIA_FILE}`  |             |               |
| `{e_MEDIA_VIDEO}` |             |               |
| `{e_MEDIA_IMAGE}` |             |               |

```

				'{e_MEDIA_ICON}',
				'{e_AVATAR}',
				'{e_WEB_JS}',
				'{e_WEB_CSS}',
				'{e_WEB_IMAGE}',
		//		'{e_WEB_PACK}',
				"{e_IMAGE_ABS}",
				"{e_THEME_ABS}",
				"{e_IMAGE}",
				"{e_PLUGIN}",
				"{e_FILE}",
				"{e_THEME}",
				//,"{e_DOWNLOAD}"
				"{e_HANDLER}",
				"{e_MEDIA}",
				"{e_WEB}",
				"{THEME}",
				"{THEME_ABS}",
				"{e_ADMIN}",
				"{e_BASE}",
				"{e_CORE}",
				"{e_SYSTEM}",
```


# Constants

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}

## Introduction

.....

## Directory constants

{% hint style="info" %}
In the table below `(hash)` refers to the :point\_right: [hash](https://userguide.e107.org/installation-and-maintenance/folders-files-hash#hash) generated upon installation of e107. &#x20;
{% endhint %}

| Constant                | Description | Example value                         |
| ----------------------- | ----------- | ------------------------------------- |
| e\_ADMIN                |             | /e107\_admin/                         |
| e\_ADMIN\_ABS           |             | /e107\_admin/                         |
| e\_AVATAR               |             | ./e107\_media/(hash)/avatars/         |
| e\_AVATAR\_ABS          |             | /e107\_media/(hash)/avatars/          |
| e\_AVATAR\_DEFAULT      |             | ./e107\_media/(hash)/avatars/default/ |
| e\_AVATAR\_DEFAULT\_ABS |             | /e107\_media/(hash)/avatars/default/  |
| e\_AVATAR\_UPLOAD       |             | ./e107\_media/(hash)/avatars/upload/  |
| e\_AVATAR\_UPLOAD\_ABS  |             | /e107\_media/(hash)/avatars/upload/   |
| e\_BACKUP               |             | ./e107\_system/(hash)/backup/         |
| e\_BOOTSTRAP            |             | ./e107\_web/bootstrap/                |
| e\_CACHE                |             | ./e107\_system/(hash)/cache/          |
| e\_CACHE\_CONTENT       |             | ./e107\_system/(hash)/cache/content/  |
| e\_CACHE\_DB            |             | ./e107\_system/(hash)/cache/db/       |
| e\_CACHE\_IMAGE         |             | ./e107\_system/(hash)/cache/images/   |
| e\_CACHE\_IMAGE\_ABS    |             | /e107\_system/(hash)/cache/images/    |
| e\_CACHE\_URL           |             | ./e107\_system/(hash)/cache/url/      |
| e\_CORE                 |             | ./e107\_core/                         |
| e\_CSS                  |             | /e107\_web/css/                       |
| e\_CSS\_ABS             |             | /e107\_web/css/                       |
| e\_DOCROOT              |             | C:/webdev/www/                        |
| e\_DOCS                 |             | ./e107\_docs/help/                    |
| e\_DOCS\_ABS            |             | /e107\_docs/                          |
| e\_DOWNLOAD             |             | ./e107\_media/(hash)/files/           |
| e\_FILE                 |             | ./e107\_files/                        |
| e\_FILE\_ABS            |             | /e107\_files/                         |
| e\_HANDLER              |             | ./e107\_handlers/                     |
| e\_HELP                 |             | ./e107\_docs/help/                    |
| e\_HELP\_ABS            |             | /e107\_docs/help/                     |
| e\_IMAGE                |             | ./e107\_images/                       |
| e\_IMAGE\_ABS           |             | /e107\_images/                        |
| e\_IMPORT               |             | ./e107\_system/(hash)/import/         |
| e\_IMPORT\_ABS          |             |                                       |
| e\_JS                   |             | /e107\_web/js/                        |
| e\_JS\_ABS              |             | /e107\_web/js/                        |
| e\_LANGUAGEDIR          |             | ./e107\_languages/                    |
| e\_LOG                  |             | ./e107\_system/(hash)/logs/           |
| e\_MEDIA                |             | ./e107\_media/(hash)/                 |
| e\_MEDIA\_ABS           |             | /e107\_media/(hash)/                  |
| e\_MEDIA\_BASE          |             | ./e107\_media/                        |
| e\_MEDIA\_FILE          |             | ./e107\_media/(hash)/files/           |
| e\_MEDIA\_FILE\_ABS     |             | /e107\_media/(hash)/files/            |
| e\_MEDIA\_ICON          |             | ./e107\_media/(hash)/icons/           |
| e\_MEDIA\_ICON\_ABS     |             | /e107\_media/(hash)/icons/            |
| e\_MEDIA\_IMAGE         |             | ./e107\_media/(hash)/images/          |
| e\_MEDIA\_IMAGE\_ABS    |             | /e107\_media/(hash)/images/           |
| e\_MEDIA\_VIDEO         |             | ./e107\_media/(hash)/videos/          |
| e\_MEDIA\_VIDEO\_ABS    |             | /e107\_media/(hash)/videos/           |
| e\_PLUGIN               |             | ./e107\_plugins/                      |
| e\_PLUGIN\_ABS          |             | /e107\_plugins/                       |
| e\_ROOT                 |             | C:\webdev\www\\                       |
| e\_SYSTEM               |             | ./e107\_system/(hash)/                |
| e\_SYSTEM\_BASE         |             | ./e107\_system/                       |
| e\_TEMP                 |             | ./e107\_system/(hash)/temp/           |
| e\_THEME                |             | ./e107\_themes/                       |
| e\_THEME\_ABS           |             | /e107\_themes/                        |
| e\_UPLOAD               |             | ./e107\_system/(hash)/temp/           |
| e\_WEB                  |             | ./e107\_web/                          |
| e\_WEB\_ABS             |             | /e107\_web/                           |
| e\_WEB\_CSS             |             | ./e107\_web/css/                      |
| e\_WEB\_IMAGE           |             | ./e107\_web/images/                   |
| e\_WEB\_IMAGE\_ABS      |             | /e107\_web/images/                    |
| e\_WEB\_JS              |             | ./e107\_web/js/                       |

## Path constants

| Constant      | Description | Example value |
| ------------- | ----------- | ------------- |
| e\_HTTP       |             |               |
| SITEURLBASE   |             |               |
| SITEURL       |             |               |
| e\_BASE       |             |               |
| e\_BASE\_SELF |             |               |
| e\_SELF       |             |               |
| THEME         |             |               |
| THEME\_ABS    |             |               |
| e\_ROOT       |             |               |
| e\_ROUTE      |             |               |
| e\_PAGE       |             |               |
| e\_LOGIN      |             |               |

## User constants

| Constant         | Description                                      | Example value                           |
| ---------------- | ------------------------------------------------ | --------------------------------------- |
| USER             | <p>Shows if a user is logged in<br>(boolean)</p> | 1                                       |
| USERCLASS        |                                                  |                                         |
| USERCLASS\_LIST  | Userclasses the user belongs to                  | 253,254,250,251,0                       |
| USERCURRENTVISIT | UNIX timestamp....                               | 1615651180                              |
| USEREMAIL        |                                                  | <admin@mywebsite.com>                   |
| USERID           |                                                  | 1                                       |
| USERIMAGE        |                                                  | zaqRWcP-\_400x400.jpg                   |
| USERIP           |                                                  | 0000:0000:0000:0000:0000:ffff:7f00:0001 |
| USERJOINED       |                                                  | 1588259340                              |
| USERLAN          |                                                  | English                                 |
| USERLV           |                                                  | 1615499410                              |
| USERNAME         |                                                  | Administrator                           |
| USERPHOTO        |                                                  |                                         |
| USERSIGNATURE    |                                                  |                                         |
| USERTHEME        |                                                  |                                         |
| USERTIMEZONE     |                                                  | UTC                                     |
| USERURL          |                                                  |                                         |
| USERVISITS       |                                                  | 82                                      |

## General Site Constants

| Constant        | Description | Example value                                                                                                                                                                                                                                                             |
| --------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SITEADMIN       |             | Administrator                                                                                                                                                                                                                                                             |
| SITEADMINEMAIL  |             | <admin@mywebsite.com>                                                                                                                                                                                                                                                     |
| SITEBUTTON      |             | /e107\_images/button.png                                                                                                                                                                                                                                                  |
| SITECONTACTINFO |             | \<strong class='bbcode bold bbcode-b'>My Company\</strong>\<br />13 My Address St.\<br />City, State, Country\<br />\<strong class='bbcode bold bbcode-b'>Phone:\</strong> 555-555-5555\<br />\<strong class='bbcode bold bbcode-b'>Email:\</strong> <sales@mydomain.com> |
| SITEDESCRIPTION |             |                                                                                                                                                                                                                                                                           |
| SITEDISCLAIMER  |             |                                                                                                                                                                                                                                                                           |
| SITEEMAIL       |             | <admin@mywebsite.com>                                                                                                                                                                                                                                                     |
| SITENAME        |             | MyWebsite                                                                                                                                                                                                                                                                 |
| SITETAG         |             | e107 Website System                                                                                                                                                                                                                                                       |
| SITEURL         |             | <http://clean3004.test/>                                                                                                                                                                                                                                                  |
| SITEURLBASE     |             | <http://clean3004.test>                                                                                                                                                                                                                                                   |

## Userclass constants

......

| Constant             | ID  | Description                                               |
| -------------------- | --- | --------------------------------------------------------- |
| e\_UC\_PUBLIC        | 0   |                                                           |
| e\_UC\_MAINADMIN     | 250 |                                                           |
| e\_UC\_READONLY      | 251 |                                                           |
| e\_UC\_GUEST         | 252 |                                                           |
| e\_UC\_MEMBER        | 253 |                                                           |
| e\_UC\_ADMIN         | 254 |                                                           |
| e\_UC\_NOBODY        | 255 |                                                           |
| e\_UC\_ADMINMOD      | 249 | Admins (includes main admins)                             |
| e\_UC\_MODS          | 248 | Moderators (who aren't admins)                            |
| e\_UC\_NEWUSER       | 247 | Users in 'probationary' period                            |
| e\_UC\_BOTS          | 246 | Reserved to identify search bots                          |
| e\_UC\_SPECIAL\_BASE | 243 | Assign class IDs 243 and above for fixed/special purposes |
| e\_UC\_SPECIAL\_END  | 255 | Highest 'special' class                                   |

{% hint style="info" %}
Userclass constants ID's 243 - 245 are reserved for future predefined user classes
{% endhint %}

## Language constants

| Constant    | Description | Example value |
| ----------- | ----------- | ------------- |
| e\_LAN      |             |               |
| e\_LANCODE  |             |               |
| e\_LANGUAGE |             |               |
| e\_LANLIST  |             |               |
| e\_LANQRY   |             |               |

## Development constants

// define('e*DEBUG', true); // Enable debug mode to allow displaying of errors* \
*// define('e\_HTTP\_STATIC', '*<https://static.mydomain.com/>*'); // Use a static subdomain for js/css/images etc.* \
*// define('e\_MOD\_REWRITE\_STATIC', true); // Rewrite static image urls.* \
*// define('e\_LOG\_CRITICAL', true); // log critical errors but do not display them to user.* \
*// define('e\_GIT', 'path-to-git'); // Path to GIT for developers* \
*// define('X-FRAME-SAMEORIGIN', false); // Option to override X-Frame-Options*\
&#x20;*// define('e\_PDO, true); // Enable PDO mode (used in PHP > 7 and when mysql*\* methods are not available)

| Constant                | Description | Example value |
| ----------------------- | ----------- | ------------- |
| e\_DEBUG                |             | 1             |
| e\_DEBUG\_CANONICAL     |             |               |
| e\_DEBUG\_JS\_FOOTER    |             |               |
| e\_DEVELOPER            |             | 1             |
| e\_MENU                 |             |               |
| e\_MOD\_REWRITE         |             | 1             |
| e\_MOD\_REWRITE\_MEDIA  |             | 1             |
| e\_MOD\_REWRITE\_STATIC |             | 1             |
| e\_NOCACHE              |             |               |
| e\_SECURITY\_LEVEL      |             | 5             |
| e\_SINGLE\_ENTRY        |             |               |
| e\_TOKEN                |             |               |

## Theme constants

| Constant       | Description | Example value              |
| -------------- | ----------- | -------------------------- |
| THEME          |             | ./e107\_themes/bootstrap3/ |
| THEME\_ABS     |             | /e107\_themes/bootstrap3/  |
| THEME\_LAYOUT  |             | jumbotron\_home            |
| THEME\_LEGACY  |             |                            |
| THEME\_STYLE   |             | style.css                  |
| THEME\_VERSION |             | 2.3                        |

## Plugin constants

| Constant            | Description | Example value |
| ------------------- | ----------- | ------------- |
| e\_PLUGIN\_DIR\_ABS |             |               |

### Core plugins

#### Social plugin

| Constant        | Description | Example value |
| --------------- | ----------- | ------------- |
| XURL\_FACEBOOK  |             |               |
| XURL\_TWITTER   |             |               |
| XURL\_YOUTUBE   |             |               |
| XURL\_GOOGLE    |             |               |
| XURL\_LINKEDIN  |             |               |
| XURL\_GITHUB    |             |               |
| XURL\_FLICKR    |             |               |
| XURL\_INSTAGRAM |             |               |
| XURL\_PINTEREST |             |               |
| XURL\_STEAM     |             |               |
| XURL\_VIMEO     |             |               |


# How to...

{% hint style="danger" %}
**Please note:** This page is under construction and has not been finished yet.
{% endhint %}


