Plugins embedding third-party JS additions

Registered by Greg

They are more and more nice javascript addition for website. For example:

http://o2v.net/blog/jquery-formlabels-plugin
http://designwithpc.com/Plugins/ddSlick
...

These products are client-only and don't interfere with the framework inner working. Using them is usually easy but can be made easier by slightly altering the controller so we can write embedding plugin (such as we do for tinyMCE) that can automatically provide them to the pages.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Medium
Drafter:
Greg
Direction:
Approved
Assignee:
Greg
Definition:
Approved
Series goal:
Accepted for trunk-3.x
Implementation:
Implemented
Milestone target:
milestone icon 3.5
Started by
Greg
Completed by
Greg

Related branches

Sprints

Whiteboard

Writing such a plugin is very easy:

- config/plugin.config.xml: register the class

    <class name="GUI_MyPlugin" alias="MyPlugin" plugin="MyPlugin" />

- includes/MyPlugin.class.php: implement the class

    class GUI_MyPlugin extends PHPDS_dependant implements iPHPDS_activableGUI
    {
     protected $path;

     public function construct($path = null)
 {
  $this->path = $path;
 }

 public function activate()
 {
  $file = $this->configuration['development'] ? 'jquery.MyPlugin.min.js' : 'jquery.MyPlugin.js';
  $this->template->addJsFileToHead($this->path.'/public/js/'.$file);
 }
    }

Now to use it (in a controller):

    $this->template->activatePlugin('MyPlugin');

As a php class, the plugin do whatever is needed to check environment, license, pathes, whatever.

March 2015: I've changed the API slightly and added auto-activation; see http://www.manula.com/manuals/phpdevshell/phpdevshell/1/en/topic/javascript-plugins

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.