Admin UI stuff

Multicheckbox field

How to set multicheck field

Multicheck field in admin UI


Inspiration (or core check): admin/newspost.php and field: news_render_type

Example:

 
'blank_compatibility' 		 
=> array( 
	'title' => "Checkbox check", 
	'type' => 'dropdown', 
	'data'=>'str', 
	'inline'=>true, 
	'readParms'=>array('type'=>'checkboxes'), 
	'writeParms'=>array('multiple'=>'1', 'optArray' => array('0'=>'first option', '1' => 'second option')),<br />
	'width' => 'auto', 
	'thclass' => 'left', 
	'class' => 'left', 
	'nosort' => false, 
),<br />


Explanation:
- 'data' - Data Type: string (it saves values separated by comma)
- 'type' - news uses dropdown, type checkbox is only for one value ( (0 or 1 is returned)

Inline editing:

 
'inline'=>true, 
'readParms'=>array('type'=>'checkboxes'), 

type checkboxes allows multiselect

117d9c2965fc

Options:
'multiple' - you can select more than one option

'optArray' - list of options. It's just example, you can fill it in init() method from database values. If you don't use keys, they will be 0,1,2..., but if you use keys, those ones will be used.

Example how to get data from related table:

$parents = e107::getDb()->retrieve("property_location", "*", "WHERE parent_id = 0", true);
            $parent_item[0] = "None selected";
 
            foreach($parents as $parent) {
              $parent_item[$parent['id']] = $parent['title'];
            }
	        $this->fields['parent_id']['writeParms']['optArray'] =  $parent_item;

Boolean field

Boolean type

radio buttons with enable/disable

Default generated value by plugin builder:

'redirection_status' => array ( 'title' => 'Statust', 'type' => 'boolean',
'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => array (),
'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),

The result is ON/OFF switcher

Available parameters (from official documentation)

inverse 0 or 1 Invert the values of 0 and 1. ie. "Disabled" = 1 and "Enabled" = 0.
enabled (string) Alternate text to replace "Enabled"
disabled (string) Alternate text to replace "Disabled"

The parameter to change the text to YES/NO

'redirection_status' => array ( 'title' => 'Status', 'type' => 'boolean',
'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => array (), 'writeParms' => 'label=yesno',
'class' => 'left', 'thclass' => 'left',),

Options field

How to customize options field

By default, there are only edit and delete buttons.

Available options (only tested ones):

'noselector' => true, removes option to select displayed fields in read mode
'readParms'=>'sort=1' adds sort option. It doesn't work if you add buttons manually 

Add/change your own buttons:

Change type key to be able customize those buttons:

'options' => array(
'type' => 'method',
'width' => '10%',
'forced' => true,
'thclass' => 'center last',
'class' => 'center',
'sort' => false,
),

and  add

/**
* Override the default Options field.
*
* @param $parms
* @param $value
* @param $id
* @param $attributes
*
* @return string
*/
function options($parms, $value, $id, $attributes)
{
$text = '';if($attributes['mode'] == 'read')
{

} 
return $text;
} 

Result:  no buttons

Add edit button back:  ( f.e. if you want your own icons)

parse_str(str_replace('&amp;', '&', e_QUERY), $query); //FIXME - FIX THIS
$query['action'] = 'edit';
$query['id'] = $id;
$query = http_build_query($query,null, '&amp;');

$text = "<a href='".e_SELF."?{$query}' class='btn btn-default' title='".LAN_EDIT."' data-toggle='tooltip' data-placement='left'>
".ADMIN_EDIT_ICON."</a>";

Result: only Edit button

Add delete button back: ( f.e. if you want your own icons)

$text .= $this->submit_image('menu_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', array('class' => 'action delete btn btn-default'));

Result: Edit and Delete buttons

NEW 18.12.2019

Add delete button for record deleting (tested): 

$text .= $this->submit_image('etrigger_delete['.$id.']', $id, 'delete', LAN_DELETE.' [ ID: '.$id.' ]', 
array('class' => 'action delete btn btn-danger',
'icon'=> '<i class="fa fa-trash-o"></i>'));

The different way how to do the same thing:  (the same result as default options)

$att['readParms'] = 'sort=1';

if($attributes['mode'] == 'read')
{
$text = "<div class='btn-group'>";
//add your button here
$text .= $this->renderValue('options',$value,$att,$id);
//or here
$text .= "</div>"; 
} 
return $text;

Date field

Date field (with calender)

minimal settings:

'date_added' => array ( 'title' => 'Added', 'type' => 'datestamp', 'data' => 'int' ),
'date_modified' => array ( 'title' => 'Modified', 'type' => 'datestamp', 'data' => 'int' ),

Readonly:

'date_added' => array ( 'title' => 'Added', 'type' => 'datestamp', 'data' => 'int', 'readonly' => true ),
'date_modified' => array ( 'title' => 'Modified', 'type' => 'datestamp', 'data' => 'int', 'readonly' => true ),<span></span>

Readonly has 2 modes:
1 = read-only, but only when there is a value,
2 = read-only regardless.

Correct values:

public function beforeCreate($new_data,$old_data)
{ 
if(empty($new_data['date_added']))
{
$new_data['date_added'] = time();
}
$new_data['date_modified'] = time(); 
return $new_data;
}

public function beforeUpdate($new_data, $old_data, $id)
{
$new_data['date_modified'] = time(); 
return $new_data;
}

SEF URL field

 SEF-URL field

Basic settings:

'sef' => array ( 'title' => LAN_SEFURL, 'type' => 'text', 'data' => 'str', 'writeParms' => 'size=xxlarge&sef=title' ),

Batch option: 

'news_sef' => array('title' => LAN_SEFURL, 'batch'=>1,  (....)  'writeParms'=>array('size'=>'xxlarge', 'show'=>1, 'sef'=>'news_title'))

Latest Downloads

JM Download plugin 1.2
in Category: JM Download plugin

JM Download plugin 1.2

3 weeks ago

Plugin for extending the core Download plugin. Version 1.3 on Github Replaced JM_Download plugin, Latest Releases by Father Barry,  Top Downloads menu by SecretR, AACGC Download Tracker by M@CH!N3 V 
Read more..

JM Download plugin 1.2
JM Core plugin 1.6.0
in Category: e107 plugins

JM Core plugin 1.6.0

1 month ago

The version used on this site. It fixes some core limitation via the plugin, no core changes. Check Readme at first.  Version 1.6.1 on github What is inside? - fix for missing titles in the m 
Read more..

JM Core plugin 1.6.0
ReCaptcha plugin 1.3
in Category: ReCaptcha plugin

ReCaptcha plugin 1.3

2 months ago

No CAPTCHA reCAPTCHA Captcha replacement for e107 v2.2 or higher with shortcodes.  Added shortcodes for replacing contact secure image shortcodes. Possibility to hide it from logged users.
Read more..

ReCaptcha plugin 1.3