Global Placeholders

From Cloudrexx Development Wiki
Jump to: navigation, search

There are several possibilities to make a placeholder globally available. Depending on how the placeholder works and where exactly it should be available there are different ways of implementing this.

Note: This documentation refers to version 4 or older. For newer versions of Cloudrexx, please refer to Widgets.

Make a placeholder be available everywhere

If you want your placeholder to be available (almost) everywhere (main template, content containers, content pages, mail templates, other module parts like calendar events and so on) you can customize the class \LinkGenerator located at ./core/LinkGenerator.class.php.

In its method parseTemplate() you get the raw contents before any placeholder replacement is done. This allows you to do almost anything, but you will have to search and replace your placeholder manually.

Make a placeholder be available at some places

Here's a short list of what to do to make a placeholder available at some specific places:

Make your placeholder available at Put your code here
Main template \Cx\Core\Core\Controller\Cx::finalize()
Content pages \Cx\Core\Core\Controller\Cx::parseGlobalPlaceholders()
Mail templates \MailTemplate [1]
  1. Search for "LinkSanitizer::parseTemplate"

For all other components search for "LinkSanitizer::parseTemplate" in the particular component's folder.

Make a Sigma-style placeholder available in main template

This can be done quite nicely: In your component's ComponentController class, add the preFinalize method (if not already present) and let Sigma replace your placeholder:

public function preFinalize($template) {
    $template->setVariable(array(
        // ...
    ));
}