You are here

function ctools_page_token_processing in Chaos Tool Suite (ctools) 7

A theme post_render callback to allow content type plugins to use page template variables which are not yet available when the content type is rendered.

2 calls to ctools_page_token_processing()
CtoolsPageTokens::testReplaceCallbackToken in tests/page_tokens.test
Test that we can set page tokens.
CtoolsPageTokens::testReplaceVariableToken in tests/page_tokens.test
Test that we can set page tokens.
1 string reference to 'ctools_page_token_processing'
ctools_page_alter in ./ctools.module
Implements hook_page_alter().

File

./ctools.module, line 822
CTools primary module file.

Code

function ctools_page_token_processing($children, $elements) {
  $tokens = ctools_set_page_token();
  if (!empty($tokens)) {
    foreach ($tokens as $token => $key) {
      list($type, $argument) = $key;
      switch ($type) {
        case 'variable':
          $tokens[$token] = isset($elements[$argument]) ? $elements[$argument] : '';
          break;
        case 'callback':
          if (is_string($argument) && function_exists($argument)) {
            $tokens[$token] = $argument($elements);
          }
          if (is_array($argument) && function_exists($argument[0])) {
            $function = array_shift($argument);
            $argument = array_merge(array(
              &$elements,
            ), $argument);
            $tokens[$token] = call_user_func_array($function, $argument);
          }
          break;
      }
    }
    $children = strtr($children, $tokens);
  }
  return $children;
}