I've had the the opposite problem of http://drupal.org/node/167110 for quite some time: the Setup and ICal tabs show up on every node page. Just uploaded the newest dev version today and still have the problem.
I think this has to do with the fact that I have a separate view set up to work with Organic Groups that adds a calendar to the group home pages.
If the view's URL is set to node/$group/calendar, I get a Calendar tab on the group home pages, but the Setup and ICal tabs show up everywhere. If I change the URL to nodes/$group/calendar or anything else, then I no longer get the Setup and ICal tabs except for on actual Calendars, but then no longer have the Calendar tab on my group home pages.
I found that the the problem is that in calendar_menu() and calendar_ical_menu, the items will get added if only part of the url gets matched (i.e. it was matching node, node/1, etc, and not just node/1/calendar).
I used the following to make sure that the current url matched the view's url better:
if (strpos(request_uri(), implode('/', $parts), strlen(base_path()))) {
$items[] = array(
'path' => implode('/', $parts) .'/setup',
'title' => t('Setup'),
'description' => t('Calendar setup.'),
'access' => user_access('administer views'),
'callback' => 'drupal_get_form',
'callback arguments' => array('calendar_setup_form', $view_name),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
}
Please let me know your thoughts.
Comments
Comment #1
karens commentedSee http://drupal.org/node/136968. For this to work right it needs a fix in Views.
Comment #2
kc1981 commentedI had applied the patch you supplied for Views and still had the problem until I added the if statement above to calendar_menu() and calendar_ical_menu(). Did I miss something from http://drupal.org/node/136968?
Thanks again!
Comment #3
kc1981 commentedI did some more testing and I don't think this is a Views problem, but rather has more to do with the menu system's handling of MENU_LOCAL_TASK's.
So, if in node/$group/calendar, $group is a valid group id, then Views has already registered the right URL and everything works fine.
The committed version of calendar_menu() and calendar_ical_menu(), however, always register node/$group/calendar/setup and node/$group/calendar/ical, regardless of whether $group is a valid group id or not.
If $group is only a valid nid and not a valid group id, then Views didn't register node/$group/calendar, and the system assumes that 'Setup' (with URL node/$group/calendar/setup) is just a task of node/$group the same way as Edit (with URL node/$group/edit).
So there needs to be a way in calendar_menu() and calendar_ical_menu() to check if $group is valid. The code I posted yesterday sort of works, but not exactly, so rather than doing that, I added a line in the foreach($parts) statement:
If I'm wrong about a problem here or if there is a better way to check if $group is valid, please let me know. Thanks!
Comment #4
kc1981 commentedHi, just wanted to check back on this issue.
Comment #5
karens commentedMake sure you have the latest dev version of OG, I don't thing the $group handling is in a released version yet. Also you must force the menus to be rebuilt one way or another (using the devel module or emptying the menu cache). You should not need the code above, there's substitution code in Views that checks the logic provided by OG to see if it is a valid group or not (which is why you need the version of OG that has that logic).
Comment #6
jblackhall commentedI think that there is more wrong than Views.
$group is available to use in the latest official release of OG and for the most part it is working well. However, I am still having the problem that superkc9 is having above. On any page using node/anything I get tabs for Setup and iCal. E.g. example.com/node and example.com/node/add . A calendar tab isn't displayed, but those 2 tabs are (Setup and iCal). In fact the 2 tabs are displayed for every node EXCEPT when viewing a Group node as opposed to only when viewing a calendar. So node/3 is a group and the 2 tabs aren't displayed, but node/2 is a story and the tabs are displayed. Also, the front page displays them (since it is displaying example.com/node maybe?).
These 2 tabs display on:
/node
/node/2 (a story)
/node/2/edit (editing a story)
/node/add (it doesn't even need a numeric argument)
but NOT on:
/node/add/story (no place for tabs on this page?)
/node/3 (a group)
My thoughts: they're being displayed on any node that's not defined as a group (and then /node/add/story and other "node add" pages just don't have a place for tabs)
But functionally the calendars are displaying correctly (as a tab of the groups page). So $group appears to be working, it just seems there's a little bug somewhere, which only admins would see (at least under my default settings).
I am using OG 5.x-4.0 and Calendar 5.x-1.7 btw and Drupal 5.3. Please let me know if you need more info or if there's something I've done wrong. Thanks!
Comment #7
kc1981 commentedI've been using the OG that has $group handling since I've had the problem along with the latest Views. I'm not sure exactly how to clear the menu cache, but every other menu works fine.
I'm still convinced that this is in the calendar_menu() function. The code to create the menu item gets called on every page, dynamically creating it each time.
The line
foreach (calendar_info() as $view_name => $view) {correctly finds the view/calendar with the URL node/$group/calendar.
The URL node/$group/calendar gets broken up into $parts, which then each $part is checked to see if it's $group, which the second one is.
So the line
$parts[$delta] = arg($delta);sets $parts[$delta] to whatever value happens to be returned by arg($delta).
So then in a few lines later, if we happen to be on node/3 for example,
'path' => implode('/', $parts) .'/setup',sets the path to node/3/calendar/setup and creates the menu item regardless of whether node/3 is a group node.
As I said above, if node/3 is a group node, then Views has already registered node/3/calendar as a URL using the code from OG, and so node/3/calendar/setup is a child of node/3/calendar, which is a calendar, and everything works beautifully.
If node/3 is not a group page, then node/3/calendar doesn't exist. node/3/calendar/setup is still registered, however, but this time as a child of node/3, which is why the 'Setup' tab shows up even though node/3 is not a calendar.
So, the line I added back in the earlier post
if ($part == '$group' && !og_url_group($part, '', arg($delta))) return $items;checks to see if arg($delta) is a valid group id or not using the function in OG that Views uses. If it is a group page, then it continues to build the URL. If not it returns before the URL gets registered.
Whether that's the best way to do it or not, I don't know. But arg($delta) needs to be checked as a valid group id before a menu is built.
Thanks!
Comment #8
jblackhall commentedCould you tell me how to empty the menu cache? Can this only be done manually in MySQL? If so, what do I need to clear? Thanks!
Comment #9
kc1981 commentedI cleared the entries in the cache_menu MYSQL table and the Setup tab still appears without the modifications I mentioned above.
Really, since the code in calendar_menu() is surrounded by if (!$may_cache) {}, I don't think caching would be the problem here, anyway, would it?
Thanks again!
Comment #10
kc1981 commentedAny news on this item? Thanks!
Comment #11
karens commentedEverything works correctly with latest OG, latest Calendar, and the patch at http://drupal.org/node/183191 on the latest Views. With the right code, I absolutely do not still see tabs on anything but the right pages.
Anyone who is experiencing this problem needs to make sure you have the latest versions of all of these modules and report the exact version and date info for each module. The tabs will work right but the breadcrumbs will be wrong without the Views patch.
Comment #12
karens commentedAlso, if you have never created an actual calendar view and are just using the default calendar view, make that into a regular view by choosing to 'add' it (it can keep the same url and options). There may be problems adding tabs onto default views, so check if that is the issue.
Comment #13
kc1981 commentedKaren,
I tried all of this with a fresh installation of Drupal 5.2 with clean URL's, the dev versions of Calendar (2007-Dec-02) and Date (2007-Dec-03), and the latest OG (5.x-4.1 2007-Dec-02) and Views (5.x-1.6 2007-Jul-14) with the patch.
I added the the content type 'group' and set it to use the group home page.
I added a default calendar view by clicking 'add' and a group calendar view with the url node/$group/calendar with the first argument set to an OG group nid with the additional calendar arguments. I set the page to have a menu item as a tab.
I created 1 group and 1 normal page (node/2). The Setup and ICal tabs, however, still show up on the normal page. On actual group pages, everything works fine because the tabs are moved down to the group calendar page.
Every time I look at the current code for calendar_menu(), it seems completely logical to me why they are showing up in unwanted places. calendar_menu gets called on every page, not just calendar pages. Then, calendar_info() in the foreach statement returns all the calendar views, which in my case, 2 of them with URL's of 'calendar' and 'node/$group/calendar'. Both URL's are parsed and for node/$group/calendar, $group is replaced with the nid of whatever the current page is, and then a menu item is created for it, regardless of whether node/2 is a group or not.
The only way it would not put Setup tabs on every page with a URL of node/nid is if calendar_menu was not called except on calendar pages. If my logic is wrong, please let me know!
Thanks again for all your help!
Comment #14
kc1981 commentedShould calendar_info() return something like node/3/calendar in $view['url'] instead of node/$group/calendar? Based off of the parsing of $parts I've been assuming node/$group/calendar
Thanks again!
Comment #15
kc1981 commentedI don't know if I missed something or not, but I'm still having this problem without the modifications to calendar_menu() I mentioned above. Also, as I said before, it makes perfect sense to me why the Setup tabs appear on every non-group node with the current version of the function.
Thanks!
Comment #16
kc1981 commentedDon't mean to be a bother, but I'm still having this issue unless some sort of check to make sure $group is a valid gid.
Using fresh install of Drupal 5.5 with
Calendar 5.x-1.x-dev 2007-Dec-15
OG 5.x-4.3 2007-Dec-19
Date 5.x-1.x-dev 2007-Dec-10
Views 5.x-1.6 2007-Jul-14 with patch from http://drupal.org/node/183191
The default calendar view is overidden but without changes.
I've created another view with the URL of node/$group/calendar and set the menu item to be a tab. Its first argument is set to OG: Group nid(s), with the calendar arguments following.
The tabs go away with code to validate $group.
Thanks!
Comment #17
karens commentedI'm not making changes to the 5.1 version. I'm officially recommending you move to the 5.2 version now. If you have problems in that version you can check for existing issues or add new ones. Feature requests are now getting posted to the D6 version to be back-ported to 5.2.
Got rid of tabs entirely in 5.2 because of all the problems. The settings are now in admin/settings.
Comment #18
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.