Presets, adding to a plugin

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page


Current Release 1.0.4 | | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes

How to write a plugin
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes

Presets allow the admin to save a template of their form results - so each time they create a new entry their own default settings are used.

To add a preset to your admin config page, enter the following code, replacing the array values with your own.

Before require_once(e_ADMIN."auth.php") add:

Code: sample preset code
$pst = new e_preset;
$pst->form = array("myform"); // name of the form that will have it's values saved.
$pst->page = array("download.php?create"); // display preset options on which page(s).
$pst->id = array("admin_downloads"); // unique name(s) of the preset

After require_once(e_ADMIN."auth.php") add the following line:

Code: sample preset code

Before the tag add the following:

Code: sample preset code
$preset = $pst->read_preset("admin_downloads"); // read preset values into array

So, in the example above, the preset called "admin_downloads" is saved and extracted.

Please note that your form elements must have default values in the form of either $name or $_POST['name'].

<input type='text' name='myname' value='$myname' />


<input type='text' name='myname' value='".$_POST['myname']."' />