This patch allows you to create an additional block and only show event matching a specific node type or types.
I initally started writing this with the perspective of being able to set the number of Upcoming Event blocks you wanted displayed and having block-specific settings beyond that (subject and node-filter settings).
This is much more simple so I reverted to this solution.
--- event.module.original 2005-11-13 22:34:14.000000000 -0600
+++ event.module 2005-11-13 22:33:09.000000000 -0600
@@ -1585,9 +1585,10 @@
*
* @ingroup event_block
* @param $limit The number of events that can be displayed in the block.
+* @param $node_types Array of node types to filter for.
* @return A string containing the fully themed block.
*/
-function event_block_upcoming($limit = 6) {
+function event_block_upcoming($limit = 6, $node_types = null) {
global $user;
// For two hours, we display "NOW"
$time = time() - (2 * 60 * 60);
@@ -1629,7 +1630,7 @@
$ctype = module_invoke('flexinode', 'load_content_type', substr($node->type, 10));
$node->typename = ($ctype->name ? $ctype->name : $node->type);
- if ($node->status) {
+ if ((is_array($node_types) && in_array($node->typename, $node_types) && $node->status) or (!is_array($node_types) && $node->status)) {
$items[] = theme('event_upcoming_item', $node);
$limit--;
}
You would employ it with a custom php block with code such as:
<?php echo event_block_upcoming(3, array('story','event')); ?>
The first parameter is the number of events to show and the second (because of the patch) is an array of node types to include in the block.
| Comment | File | Size | Author |
|---|---|---|---|
| event_type_filter.patch | 980 bytes | tclineks |
Comments
Comment #1
crunchywelch commentedIn theroy I like this idea, but would prefer a way to only retrieve the requested node types initially from the db instead of comparing them on the fly. What if the 5 most recent events are not the type you request? Your block will show nothing. It will require a bigger patch, but if it is not too awkward this may be nice to have.
also, please use || rather than 'or' for comparators
Comment #2
tclineks commentedYeah, it's a kludge.
I think you're incorrect about the five most recent though -- no limit is used in the query.
Didn't do a -p/-F^f there either, whoops.
I won't personally persue this further as it "works for me" and the group I hacked it out for.
Feel free to switch to 'won't fix'.
Thank you for the comparison operator tip.
Comment #3
killes@www.drop.org commentedfeeling so free.