Availability: >= 3.0

Type: Object Property

Description: Creates a clip art gallery of ready made HTML snippets that users can insert into their document.


$editor->snippets = array $snippets

When this value is set the Insert a Snippet button will appear on the tool bar. (But it won't appear if you have removed it from the tool bar or created a custom tool bar layout that does not include this button. Note that this button does not show if no snippets have been set)

The configuration for an editor is stored in the users session, storing excessive amounts of data in a session can seriously affect the performance of your server. If you are setting a large number of snippets we strongly recommend creating your own snippets browser using a dialog plugin or setting this value using the onBeforeGetSnippets plugin event instead. 

The format of the array is an associative array where the key is the name of the snippet and the value is the HTML code snippet. You can create folders by setting the value to an array that follows the same format as the main array.


$editor->snippets = array(
'Company Logo' => ' ,
'Company Address' => '2/99 Nowhere Sreet, Nowhereville',

Setting this value using a plugin: 

This method is recommended over setting the snippets property when constructing the editor.

For the purposes of this example we will call the plugin 'mySnippetsPlugin' but you may call your plugin anything just remember to change all instances of 'mySnippetsPlugin' in the example code and file names with your plugin name.

Note: because the snippets button is not shown if the snippets property is empty we must set the property to a value. We can do this from the plugin. 

Create the following file:


Place the following code inside it:

if (!defined('IN_WPRO')) exit;

wproPlugin_mySnippetsPlugin {

init(&$editor) {
// ensure that the snippets button is shown on the toolbar.
$editor->snippets = true;

onBeforeGetSnippets(&$editor) {
// Add some snippets:
$editor->snippets = array(
'Company Logo' => '',
'Company Address' => '2/99 Nowhere Sreet, Nowhereville',


Note: the onBeforeGetSnippets function will be called from within the context of a dialog window. If you are loading the snippets from a database or any other method that might require some of your application's libraries please remember to load those libraries from the onBeforeGetSnippets function. You may already have loaded some of your libraries when configuring the session engine in wysiwygPro/conf/