This is an experimental patch which demonstrates my proposed system for sorting of results returned by module_invoke_all().

The alphabetical order of module names is actually quite important in Drupal. This order determines the order in which module hooks are invoked. For example, the order of items on the user profile page is determined in part by module name. Also, the order of links below each node is influenced by module names.

This patch moves the 'read more' link to the beginning of the node links row. It does so simply by adding a weight to the $link[] where 'read more' is added. All other links need not change - their weight is assumed to be zero. To support this feature, a new module_sort_results() function was needed. That function lives in module.inc.

TODO
- get some feedback on this approach
- determine which hooks should be sortable.
- consider standardizing so each of these hooks expects an array in return, like the _link() hook. _user() currently expects a scalar.

Comments

drumm’s picture

After a very quick review this looks like it generically weights modules. I'm not sure that would be a very well understood concept by users. I think task-oriented weighting, as in filters and blocks, is the way to go. Weighting modules is a great thing for advanced Drupal user/coders, but I don't think it is good for everyone.

alexandreracine’s picture

Version: x.y.z » 4.5.0
Component: module system » block.module
Status: Active » Closed (fixed)

I can't find a module.module.

Too old.

Was for version x.y.z.

Closing.