[development] taxonomy_link doesn't make sense and link_alter hook requires more context.

adrian rossouw adrian at bryght.com
Sat Dec 2 09:23:24 UTC 2006


I'm sending this in mail form, as I'm currently in an airplane , and  
i didn't trust myself to remember to post
about it later =)


We have a link hook for a reason, yet it's impossible to add links to  
the terms.
( i wanted to add a link to the user's blog, instead of it cluttering  
up the comments / read more.).

 From the comments :
> * if (module_exists('taxonomy')) {
> *   $this->links(taxonomy_link('taxonomy terms', $node));
> * }

Umm. this doesn't make sense, as we don't use objects in drupal, and  
we have no 'links' method
defined for any object. Why should taxonomy link be called any  
differently from any other link hook ?

> function taxonomy_link($type, $node = NULL) {
>   if ($type == 'taxonomy terms' && $node != NULL) {

That kind of makes sense, Except we expressly are supposed to not call
it with module_invoke_all, which means 'taxonomy terms' is completely  
pointless
in this case. It gets even more pointless later.

>     // We call this hook again because some modules and themes call  
> taxonomy_link('taxonomy terms') directly
>     foreach (module_implements('link_alter') AS $module) {
>       $function = $module .'_link_alter';
>       $function($node, $links);
>     }

My point is they shouldn't be. calling it directly. Also, what's so  
special about this snippet of code that we can't
wrap it in drupal_get_links($links_id, $object) ? It's far more  
consistent that way, and that could be done in
themes.

The other GLARING issue is that link alter doesn't have the link type  
as one of the parameters. Imagine trying to
do a form_alter if you didn't even know which form you were busy  
altering? Crazy, right.

I hope to science it's not too late to change this. As it depreciates  
the usefulness of the _links imo.



More information about the development mailing list