Skip to content

Commit

Permalink
Add docs for the hooks that alter mosaico plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed Nov 19, 2021
1 parent af38d56 commit a2cf0bb
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,35 @@ function campaignadv_civicrm_mosaicoScriptUrlsAlter(&$scriptUrls) {
$url = CRM_Utils_System::url('civicrm/campaignadv/mosaico-js', '', TRUE, NULL, NULL, NULL, NULL);
$scriptUrls[] = $url;
}
```
```

## hook_civicrm_mosaicoPlugin(&$plugins)

This hook can be implemented to add custom JS plugins to the Mosaico object during initialization, see [here](https://github.com/voidlabs/mosaico/wiki/Mosaico-Plugins) on how plugins work in Mosaico.

Example usage:
```
/**
* Implements hook_civicrm_mosaicoPlugin().
*/
function example_civicrm_mosaicoPlugin(&$plugins) {
$plugins[] = _example_alert_plugin();
}
/**
* Example plugin to display alert on init and dispose.
*/
function _example_alert_plugin(){
$plugin = <<< JS
function(vm) {
alert("test-plugin");
return {
init: function(vm){alert("init");},
dispose: function(vm){alert("dispose");}
}
}
JS;
return $plugin;
}
```

0 comments on commit a2cf0bb

Please sign in to comment.