function cacheexclude_init in CacheExclude 6.2
Same name and namespace in other branches
- 5.2 cacheexclude.module \cacheexclude_init()
- 7.2 cacheexclude.module \cacheexclude_init()
Implementation of hook_init().
$_GET['q'] should be set by drupal_init_path() already, but some users have reported that it may not be. Just to be safe, reinitialize it if it's not already set.
File
- ./
cacheexclude.module, line 70
Code
function cacheexclude_init() {
$pages = trim(variable_get('cacheexclude_list', ''));
if (!$_GET['q']) {
drupal_init_path();
}
// If the current page is one we want to exclude from the cache,
// set the page caching to false temporarily.
if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) || drupal_match_path(drupal_get_path_alias($_GET['q']), $pages))) {
$GLOBALS['conf']['cache'] = 0;
return;
}
// Check if the current node type is one we want to exclude from the cache.
if ($node = menu_get_object('node')) {
$types = array_filter(variable_get('cacheexclude_node_types', array()));
if (in_array($node->type, $types)) {
$GLOBALS['conf']['cache'] = 0;
}
}
}