Skip to content

Preparing your v1.x plugins for v2.x

Cameron edited this page May 3, 2013 · 8 revisions

Plugins developed for v1.x of e107 will continue to work on v2.x. However, to get the most out of v2.x, we suggest the following changes be made to bring your plugin up to the new v2.x standards.

Front-end

HTML & Css

e107 v2.x follows the bootstrap standard for css. As a quick reference:

  • <input class='button' should become <input class='btn button'
  • <table class='fborder' should become <table class='table fborder'
  • Html <table> which use the class 'fcaption' on <td>, change the <td> to <th>. Using the forumheader3 in the admin area is obsolete and can be removed.

Templates

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:

require_once(e_PLUGIN."myplugin/templates/myplugin_template.php"); // v1.x
$MYPLUGIN_TEMPLATE = e107::getTemplate('myplugin');  // v2.x

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

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

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

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

The admin area of v2.x uses a special new admin handler (admin-ui).

In v2.x under '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.

The advantages of using the new admin system 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
  • Users can select which fields from your db table they wish to view - based on your predefined list.
  • Media-Manager is integrated into the system.
  • Easily add drag and drop sorting/re-ordering to your plugin.
  • Easily add batch delete, copy, featurebox creation, sitelink creation, userclass modification, etc. etc.
  • Easily add inline editing to your data.
  • Easily add tabs to keep your plugin's admin-area well organized.
Clone this wiki locally