I'm working on a site that is a database of thousands record albums and I'm attempting to create an "album of the day" block (I'm surprised there is no "node of the day" module out there). My solution has been to create a nodequeue of specific albums, create a view that passes the current day of the year as an argument, and then use this value to call the nodequeue item with that same numbered position. I do this by providing a "Default Argument" as PHP code in the "Nodequeue: Position" argument setting. Here's the code I use:
$nodequeueTotalNodes = 120;
$dayOfTheYear = date("z");
$nodeQueuePosition = $dayOfTheYear % $nodequeueTotalNodes;
return $nodeQueuePosition;The above code works to my satisfaction but my problem is I have to manually change the value of $nodequeueTotalNodes every time I add or remove an item from my nodequeue.
Is there a way to pull the total number of nodes from my queue to replace the "120" in my code above?
Comments
There are a few snippets for
There are a few snippets for counting the number of results in a view in this thread:
http://drupal.org/node/131031
I Found the Solution
I found the solution elsewhere. Here's the solution:
$nodequeueTotalNodes = db_result(db_query('SELECT COUNT(nid) FROM {nodequeue_nodes} WHERE qid = %d', $qid));$qid is the queue id #