This question is about Drupal plumbing. I know how, using the Views query builder, to render multiple taxonomy terms that are associated with a single piece of content. What I can't figure out is how Views actually queries the database to get the job done.
For example, it's easy to have Views show a list of Blog Posts that have one or more tags:
Title: "Brett Favre is Hurt"
Body: "blah blah blah"
Tags: Football, Injury
Title: "Cliff Lee Signs Contract"
Body: "blah, blah, blah"
Tags: Baseball, Free Agency, Philadelphia
What I can't seem to figure out is how Views goes about pulling the multiple tags and rendering them with each content item. The Views Preview query doesn't show any such SQL involving the taxonomy.
My guess is that a subquery of sorts is going on at the Taxonomy "field" or the query pulls multiple records and somehow groups the fields at title and body (which would seem rather inefficient).
I'm doing my best to follow Drupal standard practices for a custom module, and I'd like to know how the Drupal Views folks run these queries since they run pretty fast.
It is doing it in the pre_render() function, with a separate query, see views 2 api documentation.
When trying to figure out how Views is doing X, I always try to figure out in which handler this happens. Since all of them are separated into classes in separate files (usually below the modules/module_name folder)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With