I'm nowhere near experienced enough to attempt this, but wouldn't it be possible to add basic CCK support to the Event Module while still maintaining Flexinode support, by checking to see which module (flexinode.module or content.module) is installed?

It seems that many people (including myself) are moving toward CCK, but are somewhat trapped by the fact that the Event Module only support Flexinode at present.

Perhaps we could cobble together a 'bounty' to assist someone in making this happen?

CommentFileSizeAuthor
#15 event_19.patch1.27 KBsuttapong

Comments

killes@www.drop.org’s picture

Status: Active » Fixed

event module supports any node type it isn't tied to flexinode at all.

Timotheos’s picture

I'm using Event module with CCK and it works great.

gmak’s picture

Can you tell me which versions of Event Module & CCK you are using? When looking at the Calendar (eg. month view) do you see the 'human readable' event type or the CCK event type (ie. content_event_type)?

Thanks

gmak’s picture

Status: Fixed » Active

OK, I just downloaded the latest Event module and CCK modules. As far as I can see Event does 'support' CCK nodes, but

1. CCK node types do not appear in the event type filter on the various calendar views (month, week, day, list)
2. The node type displayed on calendar views is not the event type in human readable form, it is the CCK name (ie. "content-Test" rather than "Test")

Those are the sort of things that I was hoping we could get fixed.

The versions I'm using are:
event.module,v 1.183.2.6
content.module,v 1.56.2.3

Thanks.

karens’s picture

I can't make a patch because my version of events is too patched up, but I think there is an easy fix for this. In the function _event_get_type_control() (somewhere around line 1641) you need to change:

<?php
foreach ($results as $type) {
  if (module_hook($type, 'node_name')) {
    $items[$type] = module_invoke($type, 'node_name', $node);
  }
  elseif ($ctype = module_invoke('flexinode', 'load_content_type', substr($type, 10))) {
    $items[$type] = $ctype->name;
  }
}
?>

to

<?php
foreach ($results as $type) {
   $items[$type] = node_get_name($type);
}
?>

That's a new method for handling type names in drupal 4.7. I don't have flexinode installed so can't confirm it will also work on the flexinode types, but I think it should. It definitely works on standard content types and cck types.

Maybe someone with a clean events module can test this and create a patch if it seems to work.

gmak’s picture

I've applied the changes that you suggest. It goes some way to fully accommodating CCK, but there is still no filtering of the events when you select from the event type filter dropdown on calendar views. If you are using only flexinode, the filtering works. There is still some changes needed to get the actual 'human readable' name of the CCK node type on the calendar views (but this is covered by a previous post in this thread).

suttapong’s picture

another point is code somewhere like

 <?php
if ((event_get_types('all') + event_get_types('solo')) > 1) {
    $output .= '<div class="type">'. l('('. $node->event_node_title .')', 'event/'.gmdate('Y/m/d', $node->event_start).'/day/'.$node->type, array('title' => t('limit view to events of this type'))).'</div>'."\n";
  }
?>

change to

<?php
  if ((event_get_types('all') + event_get_types('solo')) > 1) {
    $output .= '<div class="type">'. l('('. node_get_name($node) .')', 'event/'.gmdate('Y/m/d', $node->event_start).'/day/'.$node->type, array('title' => t('limit view to events of this type'))).'</div>'."\n";
  }
?>

on every theme_event_node_*(day/week/month/table/list)

and

<?php
foreach ($results as $type) {
  $items[$type] = node_get_name($type);
}
?>

should be

<?php
foreach ($results as $type) {
  if(node_get_name($type))$items[$type] = node_get_name($type);
}
?>

it's fixed where some nodetype didn't link to event.
But the filter still didn't work.

rubenk’s picture

Took a look. As referenced here
http://drupal.org/node/41626
You should apply the same logic to the function event_page

I stuck this in under if ($types) {

      if ($name = module_hook($type, 'node_name')) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }
/** The next three else if statements...
 * ie. elseif (is_numeric($type)), or elseif (substr($type, 0, 10) == 'flexinode-')),
 * or elseif (array_key_exists($type, node_get_types()
 * are redundant but are provided for possible legacy conflicts. The is_numeric is 
 * most important if people used an integer to link to a cal with flexinode content

      elseif (is_numeric($type)) {

Notice that i changed if (is_numeric) to elseif (is_numeric)

Someone want to be kind enough to make a diff from this?

I am trying to see how to peel off the "conent-" part of cck terms off. Any thoughts?

rubenk’s picture

sorry.. I forgot to close the quote... make sure to end it in */

suttapong’s picture

ok I got a resolution for filter with CCK
try with these aroundline 283 of event.module

<?php
      elseif ($name = module_hook($type, 'node_name')) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }
?>

to

<?php
      elseif ($name = node_get_name($node)) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }
?>

it work well with CCK + eventfilter by node type
i think the old code module_hook() should be change to
node_get_name() in 4.7

rubenk’s picture

retool... could you make a diff file of the changes we just talked about with a brief smmary of the changes made and why so someone can review the patch? Thanks !

suttapong’s picture

sorry for the wrong code at

<?php
elseif ($name = node_get_name($node)) {
?>

must be

<?php
elseif ($name = node_get_name($type)) {
?>
suttapong’s picture

all what i do is
with event.module line around 1641

<?php
foreach ($results as $type) {
  if (module_hook($type, 'node_name')) {
    $items[$type] = module_invoke($type, 'node_name', $node);
  }
  elseif ($ctype = module_invoke('flexinode', 'load_content_type', substr($type, 10))) {
    $items[$type] = $ctype->name;
  }
}
?>

to

<?php
foreach ($results as $type) {
  if(node_get_name($type))$items[$type] = node_get_name($type);
}
?>

then aroundline 283 from

<?php
      elseif ($name = module_hook($type, 'node_name')) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }
?>

to

<?php
      elseif ($name = node_get_name($type)) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }
?>

and I have change with event.theme(if you need better look of CCK name see the 'human readable' event type)in calendar view
change all
$node->event_node_title
to
node_get_name($node)

sorry for too much changes I'm new for issue

suttapong’s picture

and last for filter to get work is
line 1649 of event.module

<?php
    if ($autosubmit) {
      $form['event_term_select']['#attributes'] = array('onChange'=>'this.form.submit()');
    }
?>

to

<?php
    if ($autosubmit) {
      $form['event_type_select']['#attributes'] = array('onChange'=>'this.form.submit()');
    }
?>
suttapong’s picture

StatusFileSize
new1.27 KB

thank you for patch support
from mm.co.th

suttapong’s picture

Status: Active » Needs review
killes@www.drop.org’s picture

Status: Needs review » Fixed

I've applied the patch to the cvs version, the changes will appear in the 4.7 version after the next merge.

rubenk’s picture

I thought that the cvs fork is using cde that isn't backwards compatible with 4.7. This was discussed recently in an issue where a person running drupal 4.7 was getting an "array" error. will the cvs version be backported? Thanks.

gmak’s picture

Status: Fixed » Active

I want to thank everyone who chipped put up their fixes and patches for this. It has helped me greatly. But, (there's always a but) now when selecting to filter by event type I'm getting titles for the node_X views (X=month, day, week, etc) that say "Events - Filter:" but it is not showing the 'filter selection' (eg. it should say "Events- Filter: Event Type".

This could be the final fix....

Thanks again.

rubenk’s picture

Strange. I haven't used the posted patch but using the code change I mentioned a few posts above, I am able to select a CCK nodetype from the drop down menu and when I select it I do indeed get events - filter: [cck name]. After doing so, if I click on week, day, etc. it continues to say events - filter: [cck name].

So, in short, if you are not seeing this then it is possible that somewhere between my hack and the posted patch, we lost this. - Is this indeed your problem? Any thoughts?

gmak’s picture

I'm not sure where I've missed it, but this:

if ($name = node_get_name($type)) {
        $x = module_invoke($type, 'node_name', $node);
        $temp[$x] = $type;
        $filter[] = module_invoke($type, 'node_name', $node);
      }

isn't passing a value to $filter[]. This is why I'm getting page titles like "Events - Filter:" with no 'type' being shown.

Also, I still don't have 'human readable' node types being displayed in the Recent Events block.

Any ideas?

(Once again, thanks to all who are helping me with all this stuff. I do appreciate it and hope that as I get more familiar with Drupal and PHP, I'll be able to start adding back to the community rather than just begging for help :-P )

killes@www.drop.org’s picture

Status: Active » Closed (fixed)

The 4.7 version is no longer supported. Please re-open if this still applies to a more recent version.