I created a custom module which lists the last X nodes from a certain content type, with the following query:
SELECT n.title, r.teaser, r.timestamp
FROM node n
INNER JOIN node_revisions r ON r.vid = n.vid
INNER JOIN term_node tn ON tn.nid = n.nid
INNER JOIN term_data t ON t.tid = tn.tid
WHERE t.name= 'breaking_news'
AND n.status = 1
ORDER BY n.nid DESC LIMIT 25
Then I do a node_load($nid)
to check if there is a image and an audio file inside, for example
$mynode = node_load($queryresutl->nid);
if ($mynode->field_efe_audio[0]['filepath']) {
$audio = 'yep, has audio';
}
But I've read that node_load()
could be a performance killer, so I wonder if this is true and if there's is an alternative to check fields in my module?
node_load
will query all field attached to your nodes. Other solution actually would be create a custom table that get updated on node creation/update/delete only if the current node contains an audio content, you can then just query that table. I think both solutions should be pretty much same performance, just a matter of organization – silkAdmin Sep 19 '11 at 10:38