Pixel & Tonic

Wygwam

version works on just rated
2.5 EE1 & EE2 $35
Buy Now Get Help

Using the wygwam_config Hook

Wygwam 2.0.1 added its own extension hook called “wygwam_config”. This hook will enable you to override your Wygwam fields’ CKEditor config settings right on page load, taking your Wygwam customizations to a whole new level.

If you’ve never written an ExpressionEngine extension before, you can learn how within the Docs for EE1 and EE2.

We’ve written a few sample extensions to demonstrate what you can do with the hook:

  • Wygwam Upload Tags parses your upload directory’s Server Path and URL settings for {screen_name}, {member_id}, and {group_id} tags.
  • Wygwam Super Admin Source enables the Source button for Super Admins, regardless of your Editor Configuration settings.
  • Wygwam Template Links adds a “Templates” link type to the Link dialog, making it easy to link to your site templates.

Hook Parameters

$config
The array of config settings that are about to be JSON-ified and sent to CKEditor during field initialization.
$settings
The full array of your field’s settings, as they were before being translated into the $config array.

Return Data?

Yes – your extension should return the $config array, whether or not you’ve modified it in any way.

Appearance of Hook in the Code

ft.wygwam.ee1.php (EE1)

if ($EXT->active_hook('wygwam_config'))
{
    $config = $EXT->call_extension('wygwam_config', $config, $settings);
}

ft.wygwam.ee2.php (EE2)

if ($this->EE->extensions->active_hook('wygwam_config'))
{
    $config = $this->EE->extensions->call('wygwam_config', $config, $all_settings);
}