function views_attach_plugin_display_node_content::pre_execute in Views attach 6.2
Same name and namespace in other branches
- 7.2 views_attach_plugin_display_node_content.inc \views_attach_plugin_display_node_content::pre_execute()
We have to run token replacement before the arguments are used.
File
- ./
views_attach_plugin_display_node_content.inc, line 203
Class
- views_attach_plugin_display_node_content
- The plugin that handles node-attached views.
Code
function pre_execute() {
// Call the parent setup function so we do not lose data.
parent::pre_execute();
$node = $this->view->current_node;
$node_types = $this->view->display_handler
->get_option('types');
if (!in_array($node->type, $node_types)) {
return;
}
$arg_mode = $this->view->display_handler
->get_option('argument_mode');
if (module_exists('token') && $arg_mode == 'token') {
if ($token_string = $this->view->display_handler
->get_option('default_argument')) {
// Now do the token replacement.
$token_values = views_attach_get_arguments_from_token_string($token_string, 'node', $node);
$new_args = array();
// We have to be careful to only replace arguments that have tokens.
foreach ($token_values as $key => $value) {
$new_args[$key] = $value;
}
$this->view->args = $new_args;
}
}
elseif ($arg_mode == 'nid') {
$this->view->args = array(
$node->nid,
);
}
}