diff --git a/administrator/language/en-GB/en-GB.plg_system_cache.ini b/administrator/language/en-GB/en-GB.plg_system_cache.ini index 16487999fcae3..4e72105a3ea78 100644 --- a/administrator/language/en-GB/en-GB.plg_system_cache.ini +++ b/administrator/language/en-GB/en-GB.plg_system_cache.ini @@ -5,8 +5,10 @@ PLG_CACHE_FIELD_BROWSERCACHE_DESC="If yes, use mechanism for storing page cache in the browser." PLG_CACHE_FIELD_BROWSERCACHE_LABEL="Use Browser Caching" -PLG_CACHE_FIELD_EXCLUDE_DESC="Specify which pages you wish to exclude from caching, each on a separate line. Regular expressions are supported." +PLG_CACHE_FIELD_EXCLUDE_DESC="Specify which pages you want to exclude from caching, each on a separate line. Regular expressions are supported." PLG_CACHE_FIELD_EXCLUDE_LABEL="Exclude Pages" +PLG_CACHE_FIELD_EXCLUDE_MENU_ITEMS_DESC="Select which menu items you want to exclude from caching." +PLG_CACHE_FIELD_EXCLUDE_MENU_ITEMS_LABEL="Exclude Menu Items" PLG_CACHE_FIELD_LIFETIME_DESC="Page cache lifetime in minutes." PLG_CACHE_FIELD_LIFETIME_LABEL="Cache Lifetime" PLG_CACHE_XML_DESCRIPTION="Provides page caching." diff --git a/plugins/system/cache/cache.php b/plugins/system/cache/cache.php index 14399c7cfabf1..f80ad16362614 100644 --- a/plugins/system/cache/cache.php +++ b/plugins/system/cache/cache.php @@ -121,7 +121,21 @@ public function onAfterRender() } protected function isExcluded() { - if ($exclusions = $this->params->get('exclude', '')) { + // Check if menu items have been excluded + if ($exclusions = $this->params->get('exclude_menu_items', array())) + { + // Get the current menu item + $active = JFactory::getApplication()->getMenu()->getActive(); + + if ($active && $active->id && in_array($active->id, (array) $exclusions)) + { + return true; + } + } + + // Check if regular expressions are being used + if ($exclusions = $this->params->get('exclude', '')) + { // Normalize line endings $exclusions = str_replace(array("\r\n", "\r"), "\n", $exclusions); @@ -132,11 +146,15 @@ protected function isExcluded() { $path = JUri::getInstance()->toString(array('path', 'query', 'fragment')); // Loop through each pattern - if ($exclusions) { - foreach ($exclusions as $exclusion) { + if ($exclusions) + { + foreach ($exclusions as $exclusion) + { // Make sure the exclusion has some content - if (strlen($exclusion)) { - if (preg_match('/'.$exclusion.'/is', $path, $match)) { + if (strlen($exclusion)) + { + if (preg_match('/'.$exclusion.'/is', $path, $match)) + { return true; } } diff --git a/plugins/system/cache/cache.xml b/plugins/system/cache/cache.xml index e7ffe9d53fe5c..8de72cd7bec76 100644 --- a/plugins/system/cache/cache.xml +++ b/plugins/system/cache/cache.xml @@ -28,6 +28,14 @@ + + +