function ctools_set_page_token in Chaos Tool Suite (ctools) 7
Same name and namespace in other branches
- 6 ctools.module \ctools_set_page_token()
Set a token/value pair to be replaced later in the request, specifically in ctools_page_token_processing().
Parameters
string $token: The token to be replaced later, during page rendering. This should ideally be a string inside of an HTML comment, so that if there is no replacement, the token will not render on the page. If $token is NULL, the token set is not changed, but is still returned.
string $type: The type of the token. Can be either 'variable', which will pull data directly from the page variables, or 'callback', which causes a function to be called to calculate the value. No other values are supported.
string|array $argument: For $type of:
- 'variable': argument should be the key to fetch from the $variables.
- 'callback': then it should either be the callback function name as a string, or an array that will be sent to call_user_func_array(). Argument arrays must not use array keys (i.e. $a[0] is the first and $a[1] the second element, etc.)
Return value
array A array of token/variable names to be replaced.
5 calls to ctools_set_page_token()
- CtoolsPageTokens::testSetPageToken in tests/
page_tokens.test - Test that we can set page tokens.
- CtoolsPageTokens::testSetVariableToken in tests/
page_tokens.test - Test that we can set page tokens.
- ctools_page_token_processing in ./
ctools.module - 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.
- ctools_set_callback_token in ./
ctools.module - Set a replacement token from the value of a function during #post_render.
- ctools_set_variable_token in ./
ctools.module - Set a replacement token from the containing element's children during #post_render.
1 string reference to 'ctools_set_page_token'
- ctools_reset_page_tokens in ./
ctools.module - Reset the defined page tokens within this request.
File
- ./
ctools.module, line 366 - CTools primary module file.
Code
function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
$tokens =& drupal_static('ctools_set_page_token', array());
if (isset($token)) {
$tokens[$token] = array(
$type,
$argument,
);
}
return $tokens;
}