Blocks generated by nice_menus contain links that get an "active" class depending on which page the block is being displayed on. Hence block definition should be (sorry not able to provide a patch, but it's a trivial change):
function nice_menus_block($op = 'list', $delta = 0, $edit = array()) {
global $user;
switch ($op) {
case 'list':
for ($i = 1; $i <= variable_get('nice_menus_number', '2'); $i++) {
$blocks[$i]['info'] = variable_get('nice_menus_name_'. $i, 'Nice Menu '. $i) .' (Nice Menu)';
$blocks[$i]['cache'] = BLOCK_CACHE_PER_PAGE;
}
return $blocks;
break;
Tested and working.
Comments
Comment #1
flevour commentedActually, I was tricked by some cache behaviour and I am not sure about the "tested and working" assertion I made above. Anyway, the rationale behind the patch looks right.
Comment #2
flevour commentedBlocks generated by nice_menus in "blocks" table needed their definition to be updated too. A query like this one needs to be provided in the upgrade path.
Comment #3
moshe weitzman commentedNot sure that per page is right since different users have different perms. i think per page per user is better. at that point, you could honestly go with 'no cache'
Comment #4
add1sun commentedYeah, I'm inclined to just go with NO_CACHE. Here is an untested patch.
Comment #5
flevour commentedWorks for me.
Comment #6
flevour commentedDidn't mean to change status. I'd suggest RTBC anyway.
Comment #7
add1sun commentedThanks for testing.
Comment #8
add1sun commentedfixed and released
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #10
murzWill be good to give the selecting cache type option for site administrator (disable cache, cache per role, cache per page).
Very often Nice menu module shows the menu with many items (large depth) and this generates many SQL queries and slows down the site. I have created many sites and most of it works good with "cache per page" caching of nice menu.
For example, on one site when I enable caching, each page generates 300-400 queries, when I enable it - queries decreases to 150-250 (removed many SQL queries with
drupal_lookup_path()for each menu item in nice menu).Comment #11
murzComment #12
add1sun commented@Murz, the menu changes per page and per role so caching it is basically a waste of time in most circumstances. If you really want to have this advanced option available, feel free to submit a patch but I'm not inclined to work on it myself.
Comment #13
murzIn most of times site administrator knows which menus are per-page-dependenced and which are per-role-dependenced and he can tune the cache parameter wisely for each block.
For example, I create more that 15 sites on drupal but only 1 site use menu blocks (exclude navigation block) with per-role and per-page changed menu.
I try to create and attach here a patch that adds this functionality, I hope it helps anybody else too.
Comment #14
add1sun commentedHm, it occurs to me that if we allow this as an option that will block #323784: Move JS and CSS to theme function.
Comment #15
add1sun commentedCan this module take care of this for us instead? http://drupal.org/project/blockcache_alter I'd rather not do this in Nice menus.
Comment #16
add1sun commentedyep i've looked it over and Blockcache Alter is a way to override default settings for blocks so I won't be adding this to NM.