Only this pageAll pages
Powered by GitBook
1 of 51

Developer Guide

Loading...

Getting Started

Loading...

Loading...

Loading...

Loading...

Classes and methods

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Plugin development

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Theme development

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Templates, shortcodes & constants

Loading...

Loading...

Loading...

Loading...

Loading...

How-to's / FAQs

Loading...

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:

<?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.phpand you're ready!

Welcome

Please note: This page is under construction and has not been finished yet.

Welcome to the new Developer Guide for e107.

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

You can use the menu on the left to navigate to the underlying pages.

Folder structure

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

Contains core assets. You should not make changes within this folder.

e107_handlers

No

Contains core functions and classes. You should not make changes within this folder.

e107_images

Not usually

Contains core images. You should not normally need to make changes within this folder.

e107_languages

Not the English folder.

Contains core language files.

Themes and plugins have their own language folder

e107_media

Not usually

Contains Media such as downloadable images or files which are specific to your installation.

e107_plugins

Yes

Contains all plugins, installed and uninstalled. You may manually add plugins to this folder if need be.

e107_system

Not usually

Contains private files such as logs, plugin and theme downloads which are specific to your installation.

e107_theme

Yes

Contains all themes, installed and uninstalled. You may manually add themes to this folder if need be.

e107_web

No

Contains core js and css packages.

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.

By default, all PHP errors, warnings and notices are suppressed and not visible to the public. You can use debugging to show them.

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.

Browser addon

We recommend this collection of 👉 Firefox Addons. The most important being the e107 Debugger. If you don't wish to use the debugger, you can still activate various debugging 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

As of e107 v2.3.1 - the + sign has been changed to an exclamation mark !. For example: [debug=basic!] instead of [debug=basic+]

Redirection

Please note: This page is under construction and has not been finished yet.

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

$url = "https://www.yourwebsite.com".
e107::redirect($url);
  • To redirect to the homepage, simply leave the URL blank.

e107::redirect();
  • To redirect to the Admin Area, use the value 'admin'.

e107::redirect('admin');

Styling (CSS)

Please note: This page is under construction and has not been finished yet.

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 and for snippets: 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

Introduction

Please note: This page is under construction and has not been finished yet.

How to...

Please note: This page is under construction and has not been finished yet.

Introduction

Please note: This page is under construction and has not been finished yet.

TODO:

  • Overview of folder structure with files

  • Note on upgrading v1 to v2 themes (legacy) - link to upgrading

  • Note on styling (bootstrap)

Shortcodes

Please note: This page is under construction and has not been finished yet.

Theme shortcodes

Plugin shortcodes

User Data

Please note: This page is under construction and has not been finished yet.

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.

todo: add example output

e107::user($user_id);

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

Database structure

Please note: This page is under construction and has not been finished yet.

Introduction

Best practices

  • Do not modify the core database structure

👍 Use your own tables (for example by creating a plugin) if you want to work with additional data in the database.

  • Do not (ab)use database tables and fields for other purposes

👍 Stick to purposes defined in the database tables 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.

There are several ways the database prefix is used:

  1. Recommended: It is strongly recommend to make use of the database methods. Using these methods, the database table prefix is processed automatically.

  2. By using the # sign, one can automatically refer to the database prefix. This is generally used when using the e107::getDB()->gen() method, to manually construct an SQL query.

  3. In rare cases, you may reference the MPREFIX constant. Its use is deprecated and not encouraged.

Database tables overview

TODO: Finish table below.

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

Table name
Description

admin_log

audit_log

banlist

comments

core

core_media

core_media_cat

cron

dblog

generic

Table for generic purposes. Generally used to store temporary date. Currently also used by welcome message. Developers are discouraged to use this table!

links

mail_recipients

mail_content

menus

news

news_category

online

page

page_chapters

plugin

rate

submitnews

tmp

upload

user

userclass_classes

user_extended

CSS

Please note: This page is under construction and has not been finished yet.

Introduction

...

Basic CSS methods

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

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

TODO: add examples

Preferences

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the render class object.

$pref = e107::getPref();

Retrieving preferences

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

e107::pref(type, value);

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

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

Or load a single preference value.

$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

Plugin shortcodes

myplugin_shortcodes.php

Language

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the language class object

$lng = e107::getLanguage()

Language methods

bcDefs()

Route

Please note: This page is under construction and has not been finished yet.

https://github.com/e107inc/e107/issues/3912

Plugin Builder

Please note: This page is under construction and has not been finished yet.

Introduction

By far, the quickest and easiest way to develop a plugin for e107 is to use the , because:

  • It allows you to select the database file () file from the plugin folder, or directly from the database table list, and it will generate most of the new code for the of your plugin.

  • It will generate the new meta-file, which is used during installation of your plugin and also when sharing plugins via this site.

The Plugin Builder can be found in Admin Area > Manage > Plugin Manager > Plugin Builder.

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 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

This section has not been finished yet!

Database tables

This section has not been finished yet!

field

caption

type

data

width

batch

filter

inline

validate

display

R/O

Helptip

ReadParms

WriteParms

Preferences

This section has not been finished yet!

Addons

This section has not been finished yet!

Logging

Please note: This page is under construction and has not been finished yet.

Introduction

You can log events to the admin by using the built in log class. Use the following to retrieve the alerts class object.

Logging methods

add()

Logging types

Meta

Please note: This page is under construction and has not been finished yet.

Include meta tags in the html header.

Examples

TODO: add more examples

Theme Shortcodes

Please note: This page is under construction and has not been finished yet.

Introduction

......

Common theme shortcodes

Please refer the the section

theme_shortcodes.php

👍 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 .

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".

Layout & templates

Please note: This page is under construction and has not been finished yet

Introduction

theme.php

Adding $CUSTOMPAGES to in e107 v2.x is deprecated and should be avoided!

theme.html

Plugins

Please note: This page is under construction and has not been finished yet.

Introduction

Plugin methods

load()

Load specified plugin data, can be used in conjunction with other methods.

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

Parameter

Type

Description

name

...

..

content

...

...

extended

...

...

e107::meta('keywords','some words'); 
e107::meta('apple-mobile-web-app-capable','yes'); 
$plg = e107::getPlug();
$plg->load($plugdir)

Parameter

Type

Description

Mandatory?

plugindir

string

Plugin name.

Could also be e_CURRENT_PLUGIN

Yes

Plugin Builder
plugin_sql.php
Admin-UI
plugin.xml
Plugin Manager
$log = e107::getLog();

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)

code

Custom reference code for your type of event. It should be short, ALL CAPITALS and not contain spaces.

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

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

Type

Description

E_LOG_INFORMATIVE

Informational event

E_LOG_NOTICE

Notice event

E_LOG_WARNING

Warning event

E_LOG_FATAL

Fatal event

System Logs
class theme_shortcodes extends e_shortcode
{
	
    function sc_my_shortcode()
    {
        return "Something";
    }

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

}
Theme shortcodes
theme_shortcodes.php
theme.php

Cache

Please note: This page is under construction and has not been finished yet.

Introduction

$cache = e107::getCache();

Cache methods

retrieve()

retrieve_sys()

set()

clear()

clear_sys()

Cache types

Work in progress

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)

Render

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the render class object.

$ns = e107::getRender();

Render methods

tablerender()

Send HTML to the browser for output.

$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

Unique name for what is being rendered. eg contact-menu Used in themes and plugins.

Default: default

No

return

boolean

When set to true the content is returned instead of being echoed

Default: false

No

Introduction

Please note: This page is under construction and has not been finished yet.

Plugins extended the functionality of e107 and allow for endless possibilities.

CORE/THIRD PARTY - LINK TO USER GUIDE

ARCHITECTURE

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

addons

Upgrading legacy themes

Please note: This page is under construction and has not been finished yet.

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.

  • Remove any reference to $CUSTOMPAGES and place them inside theme.xml in the layouts section.

<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() or e107::js() 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 file. ($register[] and everywhere else in theme.php)

Theme shortcodes

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 calledtheme_shortcodes.php.

Read more on theme shortcodes here:

Date

Please note: This page is under construction and has not been finished yet.

Introduction

Date methods

computeLapse()

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

Parameter
Type
Description
Mandatory?

convert_date()

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

Parameter
Type
Description
Mandatory?

The configuration of the mask formats are specified in 👉 Admin Area > Preferences > .

terms()

Return an array of language terms representing months

Parameter
Type
Description
Mandatory?

Introduction

Please note: This page is under construction and has not been finished yet.

Overview

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

Class
Description

URLs

Please note: This page is under construction and has not been finished yet.

Introduction

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

Parameter
Type
Description
Mandatory?

Examples

Example 1: Forum topic URLs

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

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:

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:

Example 2: Using optional parameters

TODO: Add examples using the options parameter

Theme Shortcodes

Database

All methods related to interaction with a database

Forms

Parser

.

Render

Preferences

Javascript

CSS

User Data

Meta

Events

Alerts

Logging

Redirection

URLs

Cache

$gen = e107::getDate();
$gen->computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long') 

older_date

integer

UNIX timestamp

Yes

newer_date

integer

UNIX timestamp

Default: current time

No

mode

boolean

if true return value is an array. Otherwise return value is a string

Default: false

No

show_secs

boolean

Default: true

No

format

string

Format of the human readable date. Options:

  • long

  • short (omits the year)

Default: long

No

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

datestamp

integer

UNIX timestamp

Yes

mask

string

Format of the human readable date. Options:

  • long

  • short

  • forum

  • relative

  • (any 👉strftime()valid string)

Default: long

No

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

type

string

Options:

  • month (August)

  • month-short (Aug)

  • day (Tuesday)

  • day-short (Tue)

  • day-shortest (Tu)

Default: month

Yes

Date Display options
e107::url($plugin, $key, $row, $options);

plugin

string

Folder name of the plugin. (will use data from e_url.php)

Yes

key

string

Unique key

Yes

row

array

Array of variable data such as id, title etc. eg. user_id, user_name

No

options

array

An associative array of additional options, with the following elements:

  • mode: abs | full (returning the absolute path or full URL)

  • query: an array of query key/value-pairs (without any URL-encoding) to append to the URL.

  • fragment: a fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.

(optional)

No

// 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);
$config['topic'] = array(
	'regex'    => '^forum/(.*)/(d*)-([w-]*)/???(.*)',
	'sef'      => 'forum/{forum_sef}/{thread_id}-{thread_sef}/',
	'redirect' => '/e107_plugins/forum/forum_viewtopic.php?id=$2'
 );
http://sitename.com/forum/my-sef-forum-name/2-my-forum-topic

Templates

Please note: This page is under construction and has not been finished yet.

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

$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

$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

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:

$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.

  • Core themes (located in e107_core/templates/ ) should be copied into e107_themes/YOURTHEME/templates/

  • 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/

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.

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.

👍 You should always include the English language files in your plugin!

Language files

File Types

There are three types of language files that can be used in your plugin.

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 👉 , files such asxxxx_menu.phpor 👉 .

Defining Language Terms

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

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

👍 Always use the format LAN_PLUGIN_{FOLDER}_{TYPE} to prevent conflicts.

Avoid duplicating terms, particularly in the admin area.

👍 If defining terms for admin, always search lan_admin.php for existing LANs which may match what you require.

Never use HTML or URLs inside LAN definitions.

👍 Use double quotes within the defines and use str_replace() or 👉 lanVars() for variables where needed.

Avoid short language strings for common words

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

👍 If embedding values into a phrase, use substitution.

Avoid using substitution terms which are real words or known BBCodes.

👍 Use brackets [..] and values such as x, y, z. See examples below.

Examples

Good

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

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

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():

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
plugin.xml
addons

Javascript

Please note: This page is under construction and has not been finished yet.

Introduction

....

Basic Javascript methods

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

e107::js($type, $data, $parm = null, $zone = null, $pre = '', $post = '')
Parameter
Value
Description
Mandatory?

type

See

Yes

data

See

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

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.

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

Example #2

Load a theme script in the footer

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

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

settings

An associative array with configuration options.

  • The array is merged directly into e107.settings.

  • 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.

Remember that loading from URL may take more time than local resources. Use dependency if needed!

JavaScript Behaviors

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

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

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.

(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.

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.

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

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".

Alerts

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the alerts class object.

Alerts methods

addSuccess()

addError()

addWarning()

addInfo()

addDebug()

Messages assigned here will only be displayed when is active.

render()

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

type & data
type & data
settings
$mes = e107::getMessage();
$mes = e107::getMessage();
$mes->addSuccess('You did it!');
$mes = e107::getMessage();
$mes->addError('There was a problem!');
$mes = e107::getMessage();
$mes->addWarning('You do not have access to this area!');
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
$mes = e107::getMessage();
$mes->addInfo('Please take note!');
echo $mes->render();
debug mode

Upgrading legacy plugins

Introduction

Back in September 2015, e107 v2.0.0 was officially released. 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.

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:

  • Ensure continued functionality of their plugins and themes in future versions of e107

  • Benefit from major performance and security enhancements.

  • Benefit from all new features and functionalities that are being developed in v2.x.

👍 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.

PHP and MySQL versions

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

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.

TIP: When updating plugins, take into consideration the latest PHP/MySQL developments to ensure continued functionality.

Check the 👉 requirements page for more information on the minimal and recommended requirements for an e107 installation.

Minimum and recommended changes

Minimum Changes:

  • Include a plugin.xml file

Recommended Changes:

  • Include a plugin.xml file

  • Use e107's Forms class for all form elements.

  • Use 👉 Bootstrap HTML/CSS standards in your templates and/or HTML markup

  • Upgrade e107 addons (e_xxxx.php files) to v2.x standards

  • Upgrade language-files 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.

Developers are strongly encouraged to make use of e107's standard classes & methods

TODO: Provide examples of legacy methods

Frontend

HTML & CSS

e107 v2.x follows the bootstrap standard for 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>.

  • Using the forumheader3 class in the Admin Area is obsolete and can be removed.

Templates

👍 TIP: Read more about templates & shortcodes

Loading Templates

e107 v2.x uses a new template loading system.

Plugin templates should be stored in e107_plugins/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:

// 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:

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

👍 TIP: Read more about the parsing methods

Declaring the HTML Template

eg. If your file is called myplugin_template.php , within this file you might see something like this:

$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' {---}.

👍 TIP: Read more about shortcodes

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/)

Example:

// 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:

$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).

In the Plugin Manager you will find something called "Plugin Builder". It allows you to select your e107 *_sql 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 meta-file, which is used during installation of your plugin.

👍 It is strongly recommended for plugin developers to upgrade their Admin Area using the Plugin Builder.

Migrating plugin preferences

👍 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 preference table.

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:

$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
Core Shortcodes
Shortcodes
Plugin Builder

Database

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the database class object

$sql = e107::getDb();

Basic database methods

select()

Selecting data from a database table

$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

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

Example #2: Using arguments

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

Example #3: Using arguments with noWhere option

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

Example #4: BIND support

$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:

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

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

insert()

Inserting data into a database table:

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

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

update()

Updating information in a database:

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

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

retrieve()

Combined select() and fetch() method.

$sql->retrieve($table = null, $fields = null, $where = null, $multi = false, $indexField = null, $debug = false)
Parameter
Type
Description

table

string

Name of the database table to retrieve data from.

If empty, enters fetch only mode

fields

string

Comma separated list of fields or "*" or a single field name (get one); If $fields is of type boolean and $where is not found, $fields overrides $multi

where

string

WHERE/ORDER/LIMIT etc. clause.

multi

string

If set to true, fetch all (multi mode)

Default: false

indexField

boolean

Field name to be used for indexing when in multi mode

Default: null

debug

boolean

....

Default: false

Example #1: Get a single value

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

Example #2: Get multiple table-row values

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)

$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

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'

$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

$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.

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

gen()

Generic query function to use various SQL commands.

Example: perform a JOIN with gen():

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

Advanced database methods

connect()

$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

force a new link connection if set to true Default: false

count()

database()

$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 .

multiple

boolean

Set to true to maintain connection to a secondary database

newLink

boolean

force a new link connection if set to true Default: false

getLastErrorNumber()

getLastErrorText()

Forms

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the form class object

Forms methods

open()

Returns a form opening tag.

close()

Returns a form closing tag

text()

Returns a text field form element

textarea()

bbarea()

select()

checkbox()

hidden()

button()

carousel()

Render a Bootstrap carousel

tabs()

Render Bootstrap tabs

datepicker()

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

TODO: Clarify possible options and add more examples

Examples:

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

Parameter

Type

Description

Mandatory

name

string

Name of the form

Yes

mode

string

post | get 'post' by default

No

target

string

The request URL e_REQUEST_URI by default

No

options

array

Specify options such as class or autocomplete

  • autocomplete - on/off (boolean)

  • class - (any string)

  • ...

No

$frm->close();
$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

Specify options such as class, size or selectize

  • class: (any string)

  • size: mini, small, medium, large, xlarge, xxlarge

  • selectize: array with selectize.js options

$frm->textarea($name, $value, $rows, $cols, $options, $counter);
$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

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 But you can also use the name of the plugin (e.g. forum) if the plugin provides a bbcode_template.php

No

mediaCat

string

Name of the media catalog to use (default: _common)

Is only used by TinyMCE plugin (if installed and used)

No

size

string

Size of the bbarea/editor. Use one of the following values: tiny, small, medium, large (default: large)

No

options

array

Array with options to use with the editor: id: string - In case the bbarea/editor id should be different to the name class: string - the css classes to use counter: boolean - Show a character counter wysiwyg: boolean/string -

  • False in case you want disable the wysiwyg editor for this field and use the default bbcode editor.

  • True to enable the current installed (and enabled) wysiwyg editor

  • Name of the editor (e.g. tinymce4 or simplemde) to use, in case wysiwyg is generally enabled and the supplied editor is installed.

No

$frm->select($name,$option_array,$selected,$options,$defaultBlank);
$frm->checkbox($name,$value,$checked,$options);
$frm->hidden($name,$value,$options);
$frm->button($name,$value,$action,$label,$options);
$frm->carousel($name, $array, $options);
$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);
$frm->tabs($array,$options);
$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. 
$frm->datepicker($name, $datestamp = false, $options = null)

Parameter

Type

Description

Mandatory?

name

string

The name of the field

Yes

datestamp

integer|boolean

UNIX timestamp. Set the default value of the field.

Default: false

No

options

array|string

Available options (see examples below):

  • mode - 'date' or 'datetime'

  • format -

  • timezone

  • size

  • required (true/false)

  • firstDay

  • disabled

  • placeholder

Default: null

No

$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');
MPREFIX

Parser

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the parser class object.

$tp = e107::getParser();

Parser methods

toHTML()

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

$tp->toHTML($text, $parseBB = false, $modifiers = '', $postID = '', $wrap = false)
Parameter
Type
Description
Mandatory?

text

string

text or HTML to be parsed

Yes

bparseBB

boolean

set to true to parse BBcodes into HTML

No

modifiers

string

Choose from pre-defined .

No

postID

No

wrap

boolean

Default: false

No

Example

$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.

$tp->toDate($datestamp = null, $format = 'short')
Parameter
Type
Description
Mandatory?

datestamp

unix timestamp

Yes

format

string

short - Short date format as defined in admin preferences long - Long date format as defined in admin preferences relative - relative time format. eg. "2 days ago" Default: short

toText()

Convert html to plain text.

$tp->toText(string);

createConstants()

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

$tp->createConstants(string);

replaceConstants()

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

$tp->replaceConstants(string);

parseTemplate()

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

$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.

$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.

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

toGlyph()

Convert a glyph name into Html. Just choose an icon from Font Awesome and remove the first 'fa' Templates may also use the following shortcode: which calls the same function.

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

Advanced settings:

$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.

$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.

echo $tp->toAvatar(); // render avatar of the current user. 
$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.

$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 of variables, in language files for example.

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

TODO: Convert below code into readable tables with proper descriptions

// 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

TODO: Convert below code into readable tables with proper descriptions

// 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
			)
	);

Parser modifiers

Core Shortcodes

Please note: This page is under construction and has not been finished yet.

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 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

types: news | page limit: (integer) (default is 5)

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}",
tablerender()

Events

Please note: This page is under construction and has not been finished yet.

Introduction

Plugin developers can hook into various e107 core events and trigger functions of their own. Typically, an e_event.php file is used to store this information since it is loaded with every page.

From e107 version 2.1.2 onwards you can use e_event.php addon to catch the events instead of using e_module.php

Events methods

register()

Parameter
Description
Mandatory?

name

The event you wish to hook into. ()

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

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

Example 1: trigger myFunction() on user login.

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

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

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

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

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

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.

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

The name of the event you wish to trigger (new event name). Format: plugindir_eventname (see example above).

Yes

data

The data that you wish to send alongside the event

No

Core Event triggers

User Event Triggers

Basic user functions

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

see tables below

Installation & configuration

Please note: This page is under construction and has not been finished yet.

Introduction

TODO:

  • overview of install & config files (theme.xml & theme_config.php)

  • highlight some options

  • refer to example themes (bootstrap3)

theme.xml

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

👍 TIP: To create a new theme.xml file or derive one from an existing v1.x theme.php file use the conversion tool in the Admin Area > Theme Manager > Tools (/e107_admin/theme.php?mode=convert)

Please note: Unlike plugin.xml, the theme.xml file is not intended to replace the theme.php file. Instead, theme.xml works alongside theme.php to provide (meta)data about the theme itself.

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.

<?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="[email protected]" 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

TODO: Provide minimal required theme.xml example

e107Theme

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

<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

The version of the theme

(semantic versioning)

3.0

Yes

date

The date when the theme was released (latest version). (yyyy-mm-dd)

2020-30-12

Yes

compatibility

The minimum version of e107 required to use the theme.

(semantic versioning)

2.1.0

Yes

price

In case of a commercial theme: the sales price of the theme.

(xx.xx format)

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

In case of a commercial theme: the direct URL to the specific theme.

When the user clicks to download your theme, the URL you have provided will be loaded.

❗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.

No

👍 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". Just package the theme's zip file with only the theme.xml and any images (including screenshots), excluding .php, .css files etc. before sharing it in the 👉 developers area on e107.org. When the user clicks to download the theme, it will display the URL you have provided.

In previous versions of e107, the attribute releaseUrl was used. This attribute is deprecated and should be removed.

Author

Identifies the theme author and highlights some information.

<author name="e107 Inc" email="[email protected]" url="https//e107.org" />

👍 Note the / to close the tag at the end.

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 > page.

[email protected]

Yes

url

A link to the author's website. A link to it is displayed on the Admin Area > page.

https://www.e107.org

Yes

description

A brief description of your theme. Displayed on the Admin Area > page.

Example description of your choice.

No

Summary

A text that shortly summarises the theme.

<summary>Bootstrap3 e107 theme</summary>

TODO: Check if using LAN is possible

Description

A text that provides a more elaborate description of the theme.

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

TODO: Check if using LAN is possible.

Category

<category>generic</category>

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

  • Generic

  • Adult

  • Blog

  • Corporate

  • Gaming

  • News

Plugins

In this section, theme designers can include plugins that they intend to be used with the theme. In the 👉 "Theme Manager" > Site Theme > "Suggested Plugin" section with buttons for those plugins that the user can click on to install them.

<plugins>
    ...
</plugins>

plugin

<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

For plugins that are included in e107 by default, use "core".

For third-party plugins ....

core

Yes

TODO: check format for third-party plugins.

Keywords

The keywords associated with the theme. They are used when searching for plugins either through the Admin Area or on 👉 https://www.e107.org/themes.

<keywords>
		...
</keywords>

word

	<keywords>
		<word>bootstrap</word>
	</keywords>

Screenshots

Each theme can contain one or more screenshots. These screenshots are displayed in the Admin Area and on 👉 https://www.e107.org/themes.

	<screenshots>
		...
	</screenshots>

image

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

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

Libraries

TODO: provide explanation

<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

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

Attribute

Description

Example

Mandatory?

name

Name of the library

bootstrap.editable

Yes

version

Version of the library. (semantic versioning)

3

No

scope

The area in which the library is included. Possible values:

  • front

  • admin

  • wysiwyg

Can be multiple if separated by comma

admin

Yes

Stylesheets

	<stylesheets>
		...
	</stylesheets>

css

<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'/>

Attribute

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

TODO: asterix (*) usage?

Layouts

<layouts>
    ...
</layouts>

Each theme can contain various layouts. Additionally, each layout can be used for specific custom pages and each layout can have specific menu presets.

Layout

<layout name='modern_business_home' title='Modern Business: Home page carousel with fixed custom-menus' />
Attribute
Description
Example
Mandatory?

name

Shortname of the layout

(use underscores)

jumbotron_home

Yes

title

Descriptive title of the layout

Home page carousel with fixed custom-menus

Yes

default

Indicates whether a layout is the default layout to be used. There can only be one default layout.

Boolean - defaults to 'false'

true

No

preview

A preview image (thumbnail) of the layout.

(recommended dimensions?)

preview.png

No

previewFull

A preview image of the layout (full size)

(recommended dimensions?)

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 👉 "Theme Manager" > Site Theme > > Layouts section

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

👍 You can use the constant FRONTPAGE to refer to the currently set 👉 frontpage setting.

Using the e_ROUTE constant

Adding $CUSTOMPAGES to theme.php in e107 v2.x is deprecated and should be avoided!

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

pref

name, (value)

theme_config.php

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

👍 If you want users to b e able to set specific theme preferences, use the theme_config.php file.

Example

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:

  1. inside the root of the theme folder (e107_themes/yourtheme)

  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.

👍 TIP: To insert more favicons, you can use the 👉 Meta Tags

https://direct-path-to-purchase-page.com
Theme Manager
Theme Manager
Theme Manager

Admin-UI (User Interface)

Please note: This page is under construction and has not been finished yet.

Introduction

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

TODO: explain what it is and what it does

Advantages of the Admin-UI

👍 The advantages of using the new 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.

👍 TIP: The 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.

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.

It is strongly recommended to use admin_config.php as the filename!

<?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

This section will summarize the various options which may be used while utilizing the Admin-UI class.

Please note that the documentation for this section is a work-in-progress. Thank you for your patience!

class plugin_blank_admin

extends e_admin_dispatcher

$modes

...

class plugin_blank_admin_ui

extends e_admin_ui

$fields

Database fields are defined by the $fields value in the Admin-UI class.

Example:

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

public, guest, nobody, member, admin, main, classes (comma separated)

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:

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).

  • field2 represents the field which is the parent

  • field3 represents the field which is the child

Examples

Examples can be found in the forum and download plugin.

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

Plugin Builder

Installation & configuration

Please note: This page is under construction and has not been finished yet.

Introduction

Folder structure & files

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

Note: Please replace the cursive plugin with the name of the plugin folder. (*menu.php, *_setup.php, *_shortcodes.php, *_sql.php).

TIP: the _blank plugin contains useful examples as reference material.

Filename / Foldername
Description
Mandatory?

languages (folder)

Contains the

English language files

templates (folder)

Contains all the meta data needed for the plugin to be installed and configured on a basic level.

Yes

No

Allow to run code before or after (un)installing the plugin, or to set checks for newer plugin versions.

No

...

No

Contains the database structure.

No

Contains the configuration.

No

e_*.php addons

.

No

plugin.xml

Elements & attributes

Element
Sub
Attributes
Text / Value
Mandatory?

<e107Plugin>

Yes

name

Yes

version

Yes

date

Yes

lan

No

compatibility

Yes

installRequired

Yes

<author>

name

Yes

url

Yes

email

Yes

<description>

Textual description of the plugin

Yes

lan

LAN reference to the description

No

<copyright>

Copyright text

?

<category>

Plugin category. Choose from: - settings - users - content - tools - manage - misc - menu - about

Yes

<keywords>

No

<word>

Keyword

No

<adminLinks>

No

<link>

Yes

url

URL of the link

Yes

description

Description of the link

Yes

icons

icon path

Yes

<sitelinks>

No

<link>

Link name

Yes

url

URL of the link

Yes

<pluginPrefs>

No

<pref>

Value of the pref

Yes

name

Name of the pref

Yes

<dependencies>

No

<plugin>

No

name

Yes

min_version

No

<PHP>

No

name

Yes (= core)

min_version

Yes

<MySQL>

No

name

Yes (= server)

min_version

Yes

<extension>

No

name

Yes

min version

No

<userClasses>

No

<class>

Yes

name

class_name (lowercase)

Yes

description

Description of the userclass

Yes

<extendedFields>

No

<field>

Yes

name

Name of the EUF

Yes

type

Type of the EUF. Choose from:

  • EUF_TEXT

  • EUF_RADIO

  • EUF_DROPDOWN

  • EUF_DB_FIELD

  • EUF_TEXTAREA

  • EUF_INTEGER

  • EUF_DATE

  • EUF_LANGUAGE

  • EUF_PREDEFINED

  • EUF_CHECKBOX

  • EUF_PREFIELD

  • EUF_ADDON

  • EUF_COUNTRY

  • EUF_RICHTEXTAREA

Yes

default

Yes

active

true/false

Yes

Examples

Simple

<?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

<?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 👉 "Find Plugins".

Attribute
Description

Price

Purchasing price of the plugin (in xx.xx format). Example: 25.00

Currency

Currency codes (ISO 4217) Example: EUR

URL

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.

❗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.

Example

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

plugin_menu.php

....

plugin_setup.php

Do not forget to use your plugin name in the filename, e.g. "myplugin_setup.php"

TODO: Add this section, provide example.

plugin_shortcodes.php

Please refer to the Plugin shortcodes page

plugin_sql.php

Do not forget to use your plugin name in the filename, e.g. "myplugin_sql.php"

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

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.

👍TIP: To check if the table structure is still valid, run 👉"Admin Area > Tools > Database > Check for Updates"

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.

  • 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.

  • but fails silently when trying to update. In that case remove the first "NULL" and run the the "Check for updates" again.

👍TIP: Check the blank_setup.php file or the forum_setup.php file for examples on renaming/dropping/modifying tables, fields and indexes.

Example

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 shortcodes
Admin-UI (User Interface)
language files
plugin.xml
plugin_menu.php
plugin_setup.php
plugin_shortcodes.php
plugin_sql.php
admin_config.php
Admin UI
See addons

Constants

Please note: This page is under construction and has not been finished yet.

Introduction

.....

Directory constants

In the table below (hash) refers to the 👉 hash generated upon installation of e107.

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

Shows if a user is logged in (boolean)

1

USERCLASS

USERCLASS_LIST

Userclasses the user belongs to

253,254,250,251,0

USERCURRENTVISIT

UNIX timestamp....

1615651180

USEREMAIL

[email protected]

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

[email protected]

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> [email protected]

SITEDESCRIPTION

SITEDISCLAIMER

SITEEMAIL

[email protected]

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

Userclass constants ID's 243 - 245 are reserved for future predefined user classes

Language constants

Constant

Description

Example value

e_LAN

e_LANCODE

e_LANGUAGE

e_LANLIST

e_LANQRY

Development constants

// define('eDEBUG', 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 // 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

Extending core functionality (addons)

Please note: This page is under construction and has not been finished yet.

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.

Please note: If addons are added after plugin installation, you may need to run the 👉 "Scan plugin directories" option in Admin Area > Tools > Database.

TIP: The _blank plugin in the e107_plugins folder contains example addons that may be an easy reference for you.

Overview of all plugin addons

Name

Description

Allows to extend areas of the

Allows a plugin to add customized BBCodes.

Allows a plugin to override the default 👉

Allows a plugin to add additional 👉 (or 'cronjobs') to e107.

Adds custom plugin information to the dashboard of e107's admin area.

Deprecated! Use instead.

Allows a plugin to easily hook into system events and trigger their own methods/functions.

Allows a plugin to generate content for the 👉.

Allows a plugin to include code in the footer of every page of the site

Allows a plugin developer to add their plugin as a 👉 option.

Allows a plugin to create automated entries for the 👉.

Allows a plugin developer to add data to <head> of every page.

Deprecated!

Allowed plugin developers to add information to the plugin configuration page sidebar. This has now been integrated within the through the renderHelp() method.

Deprecated! Use instead.

Allows a plugin to include a third-party library.

Deprecated!

Use instead.

Allows a plugin to hook into the 👉

Allows a plugin to use e107's mailout feature for bulk mailing.

Provide configuration options for each instance of the plugin's menus.

Deprecated!

Use instead.

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.

Adds a plugin to the section in e107's admin area.

Allows a plugin to hook into all pages at the end (after closing </html>)

Allows a plugin to hook into e107's

Allows a plugin developer to specify content that is displayed in printer-friendly format.

Adds a plugin to the RSS plugin, and generates RSS feeds.

Adds a plugin to the search which generates 'related' links in news items and pages.

Adds a plugin to the 👉.

Allows a plugin to make their shortcodes available to core templates and templates of other plugins.

Allows a plugin to automatically generate 👉 links

Deprecated! Use instead.

Deprecated! Use instead.

Allows a plugin to set categories for 👉

Provides a simple way to add mod-rewrite redirects to a plugin's page. Used to create search-engine-friendly URLs through the method.

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

👍 Be sure to replace plugindir with your plugin's directory name in all examples below.

e_admin.php

TODO: Add example. See social plugin for an example.

e_bb.php

TODO: Add example.

e_comment.php

TODO: Add example. See social plugin for an example.

e_cron.php

This addon allows a plugin to add additional scheduled task options to e107. (see Admin Area > Tools > Scheduled Tasks).

Example:

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.

Previously, the e_latest and e_status addons were used separately for this. They have now been incorporated into the e_dashboard addon.

Example:

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

Deprecated! This addon has been deprecated. Use e_print.php instead.

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.

You can make use of the event methods and event triggers.

Example:

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

TODO: Add example.

e_footer.php

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

Please find an example in the "tinymce4" plugin.

e_frontpage.php

This addon allows a plugin developer to add their plugin as a 👉Frontpage option.

Example:

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

TODO: Add example. See "news" plugin folder for an example.

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(), e107::css() or e107::meta()

Warning: Output should never be echoed or printed from this file!

Example:

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

Deprecated! This addon allowed plugin developers to add information to the plugin configuration page sidebar. This has now been integrated within the Admin-UI through the renderHelp() method.

e_latest.php

Deprecated! This addon has been deprecated. Use e_dashboard.php instead.

e_library.php

Please find an example in the "_blank" plugin.

e_linkgen.php

Deprecated! This addon has been deprecated. Use e_sitelink.php instead.

e_list.php

TODO: Add example.

e_mailout.php

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

Please find an example in the "newsletter" plugin.

e_menu.php

This addon provides configuration options for each instance of the plugin's menus.

The e_menu.php addon is a replacement for the old config.php file used in e107 v1.x.

Example:

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

Deprecated! This addon has been deprecated. Use e_header.php instead.

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.

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 👉 Notify section in the Admin Area and allows a plugin to send notifications.

Example:

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:

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 👉 output buffering.

e_parse.php

This addon allows to hook into e107's parser methods

Example:

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:

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:

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.

Example:

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:

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.

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.

Example:

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'.

Example:

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

Deprecated! This addon has been deprecated. Use e_dashboard.php instead.

e_tohtml.php

Deprecated! This addon has been deprecated. Use e_parse.php instead.

e_upload.php

TODO: Add example.

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() method.

Example:

TODO: add 'legacy' example and explanation

TODO: e_ROUTE - https://github.com/e107inc/e107/issues/3912

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:

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);
	}
}
e_admin
Admin UI
e_bb
e_comment
comments 'engine'
e_cron
Scheduled Tasks
e_dashboard
e_emailprint
e_print
e_event
e_featurebox
Featurebox plugin
e_footer
e_frontpage
Frontpage
e_gsitemap
Google Sitemap plugin
e_header
e_help
Admin-UI
e_latest
e_dashboard
e_library
e_linkgen
e_sitelink
e_list
List Latest plugin
e_mailout
e_menu
e_meta
e_header
e_module
e_notify
notifications
e_output
e_parse
parser methods
e_print
e_rss
e_related
e_search
Search page
e_shortcode
e_sitelink
Navigation
e_status
e_dashboard
e_tohtml
e_parse
e_upload
Public Uploads
e_url
e107::url()
e_user