Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created June 22, 2012 16:40
Show Gist options
  • Save damiankloip/2973907 to your computer and use it in GitHub Desktop.
Save damiankloip/2973907 to your computer and use it in GitHub Desktop.
<?php
function get_token_value($token, $values, $view) {
$value = NULL;
$token_info = $this->get_token_argument($token);
$arg = $token_info['arg'];
$token_type = $token_info['type'];
// Collect all of the values that we intend to use as arguments of our single query.
if (isset($view->field[$arg])) {
switch ($token_type) {
case '%':
$value = $view->field[$arg]->last_render;
break;
case '!':
default:
$value = $view->field[$arg]->get_value($values);
break;
}
}
elseif (isset($view->args[$arg - 1])) {
switch ($token_type) {
case '%':
$keys = array_keys($view->argument);
$value = $view->argument[$keys[$arg - 1]]->get_title();
break;
case '!':
default:
$value = $view->args[$arg - 1];
break;
}
}
else {
$value = check_plain(trim($token, '\'"'));
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment