1 achillis Mar 07, 2018 15:02
3 yurabakhtin Mar 14, 2018 07:12
Hello @achillis, we don't want to load the files of the colorpicker on ctrl=items
if there is no input type=color
, i.e. when your plugin is not enabled.
So if you use a color input in your plugin like:
function AdminDisplayItemFormFieldset( & $params )
{
$params['Form']->begin_fieldset( 'TEST plugin' );
$params['Form']->color_input( 'color', '#F60', T_('Color'), T_('E-g: #ff0000 for red') );
$params['Form']->end_fieldset( 'Foo' );
return true;
}
you should also use the following code in the plugin:
function AdminEndHtmlHead( & $params )
{
global $ctrl, $action;
if( isset( $ctrl, $action ) &&
$ctrl == 'items' &&
in_array( $action, array( 'new', 'new_switchtab', 'copy', 'create', 'create_edit', 'create_publish', 'edit', 'edit_switchtab', 'update', 'update_edit', 'update_publish', 'extract_tags' ) ) )
{ // Initialize JS for color picker field on the edit item form:
init_colorpicker_js();
}
}
You may not use the condition && in_array( $action, array( 'new', 'new_switchtab', 'copy', 'create', 'create_edit', 'create_publish', 'edit', 'edit_switchtab', 'update', 'update_edit', 'update_publish', 'extract_tags' ) )
if you really want to load the js and css files of the colorpicker on each page of the items
controller, or if you are afraid to miss this for some new future actions.
Thanks.
This post has 1 feedback awaiting moderation...
will check