function hook_views_query_substitutions in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 6.3 docs/docs.php \hook_views_query_substitutions()
- 6.2 docs/docs.php \hook_views_query_substitutions()
- 7.3 views.api.php \hook_views_query_substitutions()
Replace special strings in the query before it is executed.
Parameters
\Drupal\views\ViewExecutable $view: The View being executed.
Return value
array An associative array where each key is a string to be replaced, and the corresponding value is its replacement. The strings to replace are often surrounded with '***', as illustrated in the example implementation.
Related topics
3 functions implement hook_views_query_substitutions()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- node_views_query_substitutions in modules/
node.views.inc - Implements hook_views_query_substitutions().
- user_views_query_substitutions in modules/
user.views.inc - Allow replacement of current userid so we can cache these queries
- views_views_query_substitutions in ./
views.module - Substitute current time; this works with cached queries.
2 invocations of hook_views_query_substitutions()
- Sql::execute in lib/
Drupal/ views/ Plugin/ views/ query/ Sql.php - Executes the query and fills the associated view object with according values.
- Sql::query in lib/
Drupal/ views/ Plugin/ views/ query/ Sql.php - Generate a query and a countquery from all of the information supplied to the object.
File
- ./
views.api.php, line 320 - Describes hooks and plugins provided by the Views module.
Code
function hook_views_query_substitutions(ViewExecutable $view) {
// Example from views_views_query_substitutions().
return array(
'***CURRENT_VERSION***' => VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
'***CURRENT_LANGUAGE***' => language(LANGUAGE_TYPE_CONTENT)->langcode,
'***DEFAULT_LANGUAGE***' => language_default()->langcode,
);
}