Forgive me if this has already been reported, but I didn't see it on the support issues page, so I'm submitting it.

The "Category Browser" menu option cannot be modified on Administrate -> Site Building -> Menus. I made a quick change in the code that fixed the issue. Diff here:

 $ diff taxonomy_browser/taxonomy_browser.module.orig taxonomy_browser/taxonomy_browser.module
31c31
<   else {
---
> //  else {
42c42
<   }
---
> //  }

The "Category Browser" menu item was only being returned from hook_menu() when cacheable menus are not wanted. This code change returns the menu item regardless. Not sure if this is The Right Thing, but it was quick and it seems to work.

Thanks for a great module! Hope the suggestion helps. Let me know if you need any other information from me to make your life easier.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru’s picture

Assigned: Unassigned » NancyDru
Status: Active » Postponed (maintainer needs more info)

The reason for including this menu item in the non-cacheable portion is so that it can be turned on and off as users get the ability to use it. Otherwise, you would have to give them the authority to disable/enable the module to rebuild the menu.

Can you explain the problem more fully, please?

 

 

BTW, diff is much more usable if you use the "-u" and "-p" options.

NancyDru’s picture

Title: Category Browser is not configurable on Administrate -> Site Building -> Menus » Category Browser is not configurable on Administer > Site Building > Menus

Hmm, I just looked at it on my site and the menu item is definitely configurable. I'm on 5.7.

aboothe726’s picture

Sure! I'll be happy to give more information.

I've attached some screen shots to this post. I'll describe what the screenshots are below, but know that in all cases I've done everything I know to make sure that the page I'm seeing reflects what Drupal thinks it is -- Refresh, Clear the cache through the Devel module, etc. Also, these screenshots are 100% reproducible, so let me know if you need more. In all the screenshots, the Category Browser has weight -10 to make sure it floats up to the top of the navigation menu and configuration section. (The next-lightest item, "Database queries," has weight 0.) I added the red boxes highlighting the Category Browser menu item myself post-screenshot, so no worries there.

If I use the stock taxonomy_browser code, then the /admin/build/menu page looks like the attachment admin-menu-screenshot-before.png. Note that the "Category Browser" menu item is configurable and enabled, but the Category Browser menu item does not appear in the navigation menu. (Again, this is not due to stale data. I refreshed the page and cleared the Drupal cache.)

If I use the stock taxonomy_browser code, then the / page looks like the attachment admin-home-screenshot-before.png. The Category Browser menu item appears in the navigation menu, but it does not float to the top like it should.

Now, if I make the following change to taxonomy_browser code (thanks for the suggestion on diff args -- you're right, that is much better):

[~/public_html/modules/taxonomy_browser] $ diff -u -p taxonomy_browser.module.orig taxonomy_browser.module
--- taxonomy_browser.module.orig        2008-05-26 23:38:42.000000000 -0500
+++ taxonomy_browser.module     2008-05-27 22:52:59.000000000 -0500
@@ -28,7 +28,7 @@ function taxonomy_browser_menu($may_cach
       'access' => user_access('administer site configuration'),
       );
   }
-  else {
+//  else {
     $items[] = array(
       'path' => 'taxonomy_browser',
       'title' => t('Category Browser'),
@@ -39,7 +39,7 @@ function taxonomy_browser_menu($may_cach
       'type' => MENU_NORMAL_ITEM);

     drupal_add_css(drupal_get_path('module', 'taxonomy_browser') .'/taxonomy_browser.css');
-  }
+//  }

   return $items;
 }

...then the menu and and home pages look like admin-menu-screenshot-after.png and admin-home-screenshot-after.png, respectively. On the menu page, note that the Content Browser menu item is configurable and appears at the top of the navigation menu. Similarly, the Content Browser menu item appears at the top of the navigation menu on the home page as well, as it should.

So, I'm definitely seeing weird behavior with the stock code, and this code change fixes it. Now, you know more about why that menu is not served when $may_cache is true -- I have experience in development, but I'm still new to the Drupal scene -- so it may be that this is a fix, but the not the right fix for this issue.

Also, here's a list of the modules I have installed on my site, in case that's useful:

[~/public_html/modules] $ ls -l
total 208
drwxr-xr-x 52 sigpboo7 sigpboo7 4096 May 27 23:04 ./
drwxr-x--- 12 sigpboo7 nobody   4096 May 26 20:55 ../
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 aggregator/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 May 26 14:33 amazon_filter/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 May 26 14:15 amazontools/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Oct  9  2007 asin/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 May 27 01:07 block/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 blog/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 blogapi/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 book/
drwxr-xr-x  4 sigpboo7 sigpboo7 4096 Apr 29 08:30 cck/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 Jan 28 18:10 color/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 comment/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 contact/
drwxr-xr-x  5 sigpboo7 sigpboo7 4096 May 25 22:39 devel/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 drupal/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 filter/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 forum/
drwxr-xr-x  5 sigpboo7 sigpboo7 4096 May 25 22:14 geshifilter/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 help/
drwxr-xr-x  4 sigpboo7 sigpboo7 4096 Apr 13 19:05 image/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Feb  6  2007 image_filter/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 legacy/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 May 21 12:45 link_node/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 Dec 11 22:20 links/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 locale/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 menu/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 node/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 Mar  7 07:55 node_type_filter/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jun 18  2007 override_node_options/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 path/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 ping/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 poll/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 profile/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 search/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 May 25 20:58 service_links/
drwxr-xr-x  4 sigpboo7 sigpboo7 4096 Jul 14  2007 smileys/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 statistics/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 system/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Dec 12 07:55 tac_lite/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 Feb 10 13:55 tagadelic/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Feb 19 07:50 tagadelic_views/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 taxonomy/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 May 27 22:52 taxonomy_browser/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 throttle/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 tracker/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 upload/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 May 27 01:28 user/
drwxr-xr-x  4 sigpboo7 sigpboo7 4096 May 26 23:54 views/
drwxr-xr-x  3 sigpboo7 sigpboo7 4096 Feb 19 07:50 vocabperms/
drwxr-xr-x  2 sigpboo7 sigpboo7 4096 Jan 28 18:10 watchdog/
drwxr-xr-x  4 sigpboo7 sigpboo7 4096 Jun 14  2007 websnapr/

Most of those modules are enabled, but not all of them. (For example, websnapr is not enabled.) If there are any modules here in particular whose enabled status you're curious about, let me know and I'll look it up.

The website I'm having the trouble on is here if you need to see it for some reason.

I hope this information is useful. Again, thanks for a great module. Let me know if there's any other way I can help!

NancyDru’s picture

Can you try going back to the stock code and then clicking reset on the menu. You'll probably need to reset the weight after that. I've seen a few cases where reset cleared up whatever was going on in the menu. If that doesn't get it, then try disabling (not uninstalling) the module and then re-enabling it.

aboothe726’s picture

Absolutely, no problem.

I disabled and re-enabled the module; the 'Category Browser' menu entry still doesn't appear when in Administration -> Site Building -> Menus. I applied my change and the menu entry showed up. I reset the entry; it still showed, which is good. I reverted to the stock code, and the menu entry disappeared again.

Honestly, I'm only running a small-time personal site. I can set up an admin access account for you if that's helpful. Would that help you to run this to ground?

Junyor’s picture

I'm seeing this as well. "Category Browser" is not displayed on the Menu configuration page (and also doesn't display in the menu when on the Menu configuration page), making it impossible to configure. It is displayed on the site home page, though.

Maybe it would be better to always have the permission to see the menu available so the menu can be put in the $may_cache section?

aboothe726’s picture

That's interesting. I was reading up on Drupal menus over lunch to figure out whether or not this menu really should be cacheable and I didn't pick up on that nuance. Is it true that you you can't cache a menu if specific permissions are required to see it?

Fortunately, that's a testable hypothesis. I'll run a quick experiment when I get home to run that, unless someone here points me to documentation that covers that particular detail about menus.

Also, after reading up on menus, I understand that the patch I've submitted is wrong. The patch returns the menu regardless of the value of $may_cache, which means that the menu item is likely to be returned twice. Obviously, that's not the right thing. If the menu should be cacheable, it should just be moved from the else up to the if. I'll submit another patch later, hopefully tonight.

Junyor’s picture

Menus can have access permissions, but if there is a variable to enable the permissions, that gets a bit tricky (I imagine).

NancyDru’s picture

If the menu item is cached, you can change the settings all day long and nothing will change. In order for the menu item to come and go with the settings, it needs to be non-cacheable.

There is a setting for whether or not TB "Requires permission" to be used. If the option is selected, you must also go to the "admin > user > access control" page and set the role to have "access taxonomy browser". If the option is not selected, then the user needs "access content" permission, which anyone on your site pretty much needs any way.

At the moment, I'm not sure a patch is necessary.

Junyor’s picture

Right. But why add a preference for a permission? Admins can just enable the menu for all users if they don't need it for specific users.

NancyDru’s picture

Junyor’s picture

So, your concern is that existing sites won't be able to use the menu because they don't know about the permission? Then, use an update to enable it by default. But I don't think that's a valid concern. Admins need to read release notes when updating modules.

NancyDru’s picture

No, my concern is fixing aboothe726's problem.

Junyor’s picture

OK....

aboothe726’s picture

The problem I'm having is that the "Category Browser" doesn't show up in the menu admin screen with the stock module definition, so I can't configure it. So long as we can get the Category Browser to show up on the menu admin screen, I'm happy :)

I think a good way to determine The Right Thing here is to look at similar modules that expose menu items that do appear in the menu admin screen and see how they handle caching. I should have some time to do that tonight, and I'll post what I find.

Junyor, I appreciate your input on this issue, and NancyDru thank you for being so on top of this. I'm not used to getting this much developer attention unless it's my own :)

Junyor’s picture

Just to clarify, I'm not a maintainer of this module, just a user experiencing this problem like you.

aboothe726’s picture

Right. Sorry for confusion. I meant that last bit just for NancyDru.

NancyDru’s picture

I want my modules to be right, so I try to get them that way.

My problem here is that it IS working right for me. What I'm having trouble with is why it is not for you. And, BTW, I have several modules that expose/hide menu items and they all work.

Perhaps I need to take you up on that offer of an admin account.

Junyor’s picture

@NancyDru: Are you logged in as user 1? Maybe that has something to do with it.

NancyDru’s picture

No, actually, user/2, but I still have admin access. Which permissions do you suspect?

NancyDru’s picture

I just logged in as an ordinary authenticated user with no special permissions and the menu item was there. I then turned on the "Requires permission" setting and the menu item went away. This is exactly what I would expect.

Junyor’s picture

I wasn't suspecting any particular permission.

Let me just start from the beginning again, in case there is some useful information I haven't conveyed. I have my site setup so that two roles (not authenticated or anonymous users) can access taxonomy browser. My user account has one of those roles plus the admin menus permission. In other words, I can see the menu item and I can admin menus. If I go to my site home page, I can see the menu item. However, I don't want the menu item there as I have an alternative way of accessing it. So, I go to the menu admin page and notice that the "Category browser" menu item is not listed in the site menu any more. It was initially listed on the admin menu page, but when I reset the menu, it no longer appeared there. Thus, I cannot disable the menu entry.

NancyDru’s picture

Okay, so what you're saying is that it worked correctly until you RESET it? That is an important piece of information.

Junyor’s picture

I've just retested using a database copy from a while back. Here's what I did:

0) Disable the "Category browser" menu item
1) Upgrade from Taxonomy Browser 5.x-1.0 (I think) to 5.x-1.2
2) View the menu admin page. The "Category browser" menu item is correctly disabled
3) Enable the "Requires permission" checkbox
4) In Access Control, enabled "access taxonomy browser" for my user's role
5) Notice that "Category browser" appears in the menu
6) Go to menu admin to disable it
7) Notice that it's already disabled and that it doesn't appear in the menu on the admin menu page (admin/build/menu)
8) Reset it
9) Notice that it's no longer available on the admin menu page

NancyDru’s picture

Thanks. That is, indeed, important information for dealing with your situation.

@aboothe726: Is this similar to what you're doing?

I'll have to study up on what a menu reset means. (Core support issue: http://drupal.org/node/264622)

NancyDru’s picture

I doubt this has any bearing on any of this, but that 'weight' setting should not be there. I will definitely remove it. Can either of you remove it and see if does anything, please?

Junyor’s picture

The menu weight? I haven't changed it and I can't admin the menu, so I can't change it now. Or some other weight?

NancyDru’s picture

I was talking about removing it directly from the module code.

    $items[] = array(
      'path' => 'taxonomy_browser',
      'title' => t('Category Browser'),
      'access' => user_access(variable_get('taxonomy_browser_need_perm', false) ? 'access taxonomy browser' : 'access content'),
      'callback' => 'taxonomy_browser_page',
      'description' => t('Find content on your own terms.'),
      'weight' => 7,
      'type' => MENU_NORMAL_ITEM,
      );

to

    $items[] = array(
      'path' => 'taxonomy_browser',
      'title' => t('Category Browser'),
      'access' => user_access(variable_get('taxonomy_browser_need_perm', false) ? 'access taxonomy browser' : 'access content'),
      'callback' => 'taxonomy_browser_page',
      'description' => t('Find content on your own terms.'),
      'type' => MENU_NORMAL_ITEM,
      );

I honestly have no idea how that got there because it is extremely rare for me to add menu weights in the code.

Junyor’s picture

Gotcha. Removing that doesn't make a difference.

NancyDru’s picture

I didn't think it would, but there was always a glimmer of hope.

aboothe726’s picture

Sorry for the radio silence on this issue.

NancyDru, I've just installed the latest version of Taxonomy Browser, which is 5.x-1.2, so I'm not upgrading. However, what Junyor's describing is very similar to what I'm doing. However, "Require Permissions" is not enabled on Taxonomy Browser for my site, but I still cannot see the "Category Browser" menu item in /admin/build/menu.

The issue that I'm having is that the "Category Browser" menu item is not configurable on /admin/build/menu, so I can't disable it.

NancyDru’s picture

Thanks.

NancyDru’s picture

Okay, I've been digging into core code on this. When you "Reset" a menu item, it is flagged as not visible, which seems to be what you are describing. That is certainly what is happening on my site. So it appears that this is normal behavior as defined by core. I disabled the module and re-enabled it and the menu item came back, but not in admin>build>menu. I also don't see the entry in the menu table.

I'm guessing that this is "normal" core behavior and probably has something to do with menu caching. I really have no idea how to fix it.

NancyDru’s picture

Junyor’s picture

Status: Postponed (maintainer needs more info) » Active

I don't think you can configure non-cached menu items.

Leeteq’s picture

I also see this "behaviour" on several D5-7 installs, also including sites with no other access control modules than core, if that may be relevant input here. As far as I can see, it is consistent behaviour. I havent seen the possibility to configure that menu on ANY of the sites.

NancyDru’s picture

Status: Active » Postponed (maintainer needs more info)

If we just go to a straight permission based menu, do you think that would solve this?

Junyor’s picture

Yes.