Droplets


Droplets are small chunks of php code (just like the code2 module) that can be included in your template or any other content section.

Including a droplet is done by encapsulating the droplet name in double square brackets.

I.e. if you want to use the droplet "ModifiedWhen" (to show the last modified date and time of the current page) you only need to add [[ModifiedWhen]] to your template or WYSIWYG contentpage.

You are encouraged to create your own droplets and share them with the community.

Installation


The Droplets management tool is installed as an admin tool. The installation is done using the usual "Add module" page in the WBCE backend.

When the installation is successfull, there is a new tool added to the Admin-Tools overview.

Clicking the tool will display the current installed droplets, and buttons to create new droplets or import existing ones.

Getting Droplets


Some ready-made Droplets are available at the WBCE AOR.

Coding Droplets


Droplets run in PHP mode, so <?php or ?> is neither necessary nor allowed in the code! If any of these tags are found in the code they will be removed. Your code will not run as expected.

The droplet code can NOT echo or print data to the output stream directly. The Droplet name is replaced by the return value of the PHP code.
Example: [[HelloWorld]]


Wrong code: echo "Hello World";

Correct code: return "Hello World";


Droplets can modify the complete page content.

When the Droplet is called, an extra variable ($wb_page_data) is made available.

This variable holds all the content of your current generated webpage.

You can modify any part of this content simply by replacing it in the variable. There is no need to return this variable, the Droplet code will process changed content automatically.


Droplets will check the PHP code you have saved for validity.

When the code will not execute correctly a red flashing icon will apear in the backend Droplets list.

The standard blue icon is no guarantee that the Droplets does what you would expect it to do, it will just tell you if the code is valid PHP code.


Droplets do not need to return any data. When you end your code with

return true;

there will not be an errormessage. The processed Droplet tag will be removed.

Getting help



If you run into issues with Droplets, have a look at the WBCE Forum.