Hook for modifying the similar nodes

Mark Theunissen - March 25, 2009 - 10:58
Project:Similar By Terms
Version:6.x-1.18
Component:Code
Category:feature request
Priority:normal
Assigned:Mark Theunissen
Status:closed
Description

I propose that the nodes array should be passed to a hook so that other modules can modify it. This arises from my need to modify the list in a way that is too customised to warrant making specific admin options.

The following code should do it. Patch attached.

<?php
// Allow modules to alter the list of nodes by implementing a hook.
// TODO: Pass by reference the $nodes array rather than returning them.
$nodes = module_invoke_all('similarterms_alter', $node_obj, $nodes);
?>

#1

Mark Theunissen - March 25, 2009 - 10:59

Note this patch also includes my critical bug report http://drupal.org/node/408262

AttachmentSize
similarterms-new_hook-413184-1.patch 1.85 KB

#2

Mark Theunissen - March 25, 2009 - 11:06

Hang on, I just realised this doesn't work properly in cases where a hook is not implemented. I'll have to implement the pass by reference to have it behave.

#3

Mark Theunissen - March 25, 2009 - 11:15

Here's another go.

AttachmentSize
similarterms-new_hook-413184-3.patch 1.94 KB

#4

rmiddle - March 29, 2009 - 22:15
Status:needs review» fixed

Committed and will be in the next release.

Thanks
Robert

#5

System Message - April 12, 2009 - 22:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.