I ran into a problem, working on a recent project: I wanted direct access to the node objects for a specific nodequeue, to make custom theming easier. The way it stands now, you must either use a view or accept the rendered output provided by nodequeue_nodes().

This patch is a small rewrite of nodequeue_nodes(). It adds a helper function, nodequeue_fetch_nodes(), which returns an ordered array of the node objects for a given queue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davideads’s picture

Version: 6.x-2.0-rc2 » 7.x-2.x-dev
FileSize
4.62 KB

Here's a better version of this patch, which properly enables random fetching, and drops display-related arguments from the fetch function signature.

ezra-g’s picture

This sounds reasonable to me . Thanks for the revised patch - I hope to review this soon,

tirdadc’s picture

This is definitely useful, it would be great seeing this integrated into the next release.

ezra-g’s picture

hope to review and commit this this coming weekend. It does need some rerolling by someone, possibly me, to remove the lowercase 'true' changes that are unrelated to this patch.

ezra-g’s picture

Status: Needs review » Needs work

I finally got a chance to give this some attention.

The code here is solid but it seems like the function naming has the potential to be confusing. nodequeue_fetch_nodes returns loaded (but not rendered) node objects, while nodequeue_fetch_front, nodequeue_fetch_back and nodequeue_fetch_random return rendered node objects. Perhaps the fetch functions should be renamed nodequeue_load_front (and so on), nodequeue_nodes would then be renamed nodequeue_view_nodes, and nodequeue_fetch_nodes would become nodequeue_load_nodes. Then, when using the load (formerly fetch) functions, module developers could simple call node_view from within their modules.

What do you think?

Thanks for your interest and patience. I'll review any feedback (or rerolls) quicker this time ;).

ezra-g’s picture

Status: Needs work » Fixed

I made those name changes and did the related refactoring. Committed. Thanks!

Status: Fixed » Closed (fixed)

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