4

If I want to theme the output of node_view_multiple() I can just set the #theme element of the renderable array generated by the node_view_multiple() function.

But, what if I'm not the one that called the node_view_multiple()? Is there a tpl file for that?

A good example would be a taxonomy term page. The taxonomy-term.tpl.php allows to theme only the term itself, not the actual list of nodes. So how can I theme that list of nodes?

Note that I don't want to theme individual nodes (that's not the scope of the question). I want to theme the list of nodes.

1

The return from node_view_multiple is supposed to be a dumb collection of node render arrays, it's not meant to be themeable in and of itself (at least not on a generic level, obviously case-by-case you can do it). The function sepecifically doesn't get involved with the theming, as that should be up to the caller to determine. So using #theme or #theme_wrappers on the outer array is the correct thing to do.

There isn't anything you can do to target other modules' use of node_view_multiple() in this respect, short of:

  1. Patching the module code
  2. Patching node_view_multiple itself so it has a default theme function, which you can then hook into.
  3. Use a broader attack like hook_page_alter() to make specific changes to specific arrays when it makes sense to.
  • Option 1 makes little sense as I need generic solution. Option 2 would be the best option, but there is no change this would go into the core :( Option 3 the same as option 1 - would work only for predetermined situations. Anyway, thanks for the clues. – SiliconMind Apr 11 '14 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.