Loss of Content Type When Selecting View Links (Month, Week, etc.)

erikwebb - October 29, 2008 - 14:24
Project:Event
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When clicking on the text links at the top of the calendar view (Month, Week, Day, List, Table), it resets any setting made by the filters, whether they be content types or terms. I've hacked around a bit and found the error to be in the event_link() function. The problem appears to be that there is no way to retrieve this data from within the function. Are these variables globally available anywhere?

Ideally, a link which reads /event/2008/10/29/table/event_type/13 is outputted as /event/2008/10/29/table.

Thank you,
Erik

#1

eridanibrew - November 10, 2008 - 01:52

I encountered the same problem, along with a second issue - I wanted to be able to pass in two or more filters and have them all on the calendar.

I'm a newbie here, only been messing with this for a few days, so I apologize in advance for any coding faux pas or whatever.

To "fix" the first problem, I changed the event.module function event_link, as suggested by erikwebb:

function event_link($type, $node = NULL, $teaser = FALSE) {
// brew added this line
global $MyFilter;
. . .
$links['event_month'] = array('title' => t('Month'),
'href' => $base .'month/'. $MyFilter, // brew replaced $node->filter,
'attributes' => array('title' => t('Month view')));

and so on for each of the subsequent links. It looks like the filter pattern was supposed to have been saved in $node, but we don't have a $node available here.

I then set the global value in function event_page, where the code sems to be using an old drupal function to parse out the multiple types in the path:

around line 418:
if (!empty($types)) {
// brew - saving the types string for use in the links
global $MyFilter;
$MyFilter = $types;
// The '+' character in a query string may be parsed as ' '.
$types = preg_split('/[+ ]/', $types);
foreach ($types as $type) {
if ($name = node_get_types('name', $type)) {
//$x = module_invoke($type, 'node_name', $node);
//$temp[$x] = $type;
//$filter[] = module_invoke($type, 'node_name', $node);
// brew replaced
$temp[$name] = $type;
$filter[] = $name;
}
}

This seems to make things work for me - I can now set a path like
event/type/type1+type2
and have the multiple types (and only them) appear in the calendar.

I of course have no idea how to submit this as a patch, I don't imagine this kludgy global is appropriate anyway. But, it at least seems to be working for me.

brew

#2

davis4104 - August 10, 2009 - 14:03

This change in function event_link in event.module seemed to fix this problem for me.

//if (!isset($node->filter)) {
if (!isset($node->event['filter'])) {
$node->filter = '';
}
else {
$node->filter = $node->event['filter'];
}

 
 

Drupal is a registered trademark of Dries Buytaert.