function token_embed_views_tokens in Token Embed Views 7
Same name and namespace in other branches
- 8 token_embed_views.tokens.inc \token_embed_views_tokens()
Implements hook_tokens().
File
- ./
token_embed_views.module, line 26 - Module to embed views using tokens
Code
function token_embed_views_tokens($type, $tokens, array $data = array(), array $options = array()) {
if ($type == 'views') {
$replacements = array();
foreach ($tokens as $token => $key) {
// Extract info.
$args = explode(':', $token);
// Remove the first element out as its not a required parameter for the views.
$token_name = array_shift($args);
// Fetch the view with all args passed to it.
$replacements[$key] = call_user_func_array('views_embed_view', $args);
}
return $replacements;
}
}