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.

CommentFileSizeAuthor
#4 nice_menus-no-cache_284294-4.patch1.27 KBadd1sun

Comments

flevour’s picture

Actually, 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.

flevour’s picture

Blocks 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.

db_query("UPDATE {nice_menus} SET cache = %d WHERE module = 'nice_menus'", BLOCK_CACHE_PER_PAGE);
moshe weitzman’s picture

Status: Needs review » Needs work

Not 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'

add1sun’s picture

Status: Needs work » Needs review
StatusFileSize
new1.27 KB

Yeah, I'm inclined to just go with NO_CACHE. Here is an untested patch.

flevour’s picture

Status: Needs review » Active

Works for me.

flevour’s picture

Status: Active » Needs review

Didn't mean to change status. I'd suggest RTBC anyway.

add1sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for testing.

add1sun’s picture

Status: Reviewed & tested by the community » Fixed

fixed and released

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

murz’s picture

Priority: Critical » Normal
Status: Closed (fixed) » Active

Will 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).

murz’s picture

Category: bug » feature
add1sun’s picture

@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.

murz’s picture

In 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.

add1sun’s picture

Hm, it occurs to me that if we allow this as an option that will block #323784: Move JS and CSS to theme function.

add1sun’s picture

Status: Active » Postponed (maintainer needs more info)

Can this module take care of this for us instead? http://drupal.org/project/blockcache_alter I'd rather not do this in Nice menus.

add1sun’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

yep 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.