Message of the Day

Events happening in the community are now at Drupal community events on www.drupal.org.
alex.a's picture

I have written a Message of the Day module which defines a block that rotates a different message every day. The messages are selected from a pool of nodes designated as messages of the day. The block displays the title of the node as a link to the node.

The block is designed to raise awareness to a subject, by displaying a relevant forum topic related to the subject of interest. In the bike advocacy site that I'm involved in (www.podilates.gr), we want to raise awareness to the need of having adequate lights when cycling at night. So we configured the message of the day block in the blue band of the Acquia Marina theme that we use.

I searched for modules related to "message" or "day" to find if this module already exists in drupal.org, but I didn't find it. If this functionality already exists in another module, please let me know. While searching, I found that the flag module provides some of the functionality I needed, so I used it to designate the nodes that are rotated in the message of the day block.

Comments

nodequeue

alex.a's picture

Apparently the nodequeue module does most of what I want. I'm not sure if views and nodequeue can do the rotating node yet, but I'll look into it.

I have written a short

Drave Robber's picture

I have written a short tutorial about creating 'Quote of the Day' using Views and a five-line PHP snippet. With it, one can display not only messages, but any fields (images, references) that could exist in a custom content type. One can also create 'Something of the Week/Hour/Month/other period'.

The setback is that the order is disrupted if new items are added, so it is suitable for finalized lists only. Well, this problem can probably be rectified with two or three more lines of code.

That is either insane or

Garrett Albright's picture

That is either insane or genius. I'll go with both, but with emphasis on the former. Congratulations.

Your query does not account for unpublished nodes, and may result in the View trying to display a node that the visitor cannot see.

Also, since this query will only cause a different result once a day, caching should be involved somewhere; perhaps in the View settings itself. Also, you should put curly braces around table names in your queries: SELECT nid FROM {node}… Also, eval()'d code in general should be avoided like the plague, but that's another thread.

Completely agreed with your

Drave Robber's picture

Completely agreed with your remarks on table placeholders (this is something I unfortunately often forget) and caching;

as for unpublished nodes, theoretically yes, but there already is a note about this approach being suitable for already finalized collections of items. I however added a note about this, too.

As for eval'd code – is there really an alternative for this use case? A custom module would have to be quite huge to achieve the level of flexibility Views provide.

(Edit: this was meant as a reply to Garrett's comment. Seems like I need 'moar kauphi'.)

As for eval'd code – is there

Garrett Albright's picture

As for eval'd code – is there really an alternative for this use case? A custom module would have to be quite huge to achieve the level of flexibility Views provide.

Not necessarily. Views' API lets you create your own filters for it to use. If you wanted to maintain this same approach, all you'd have to do is write a module which provides a Views filter which does this same calculation. Views' API can be pretty inscrutable at times, so I don't blame people who just say "the hell with it" and go the eval() route, but that doesn't mean it's the best way.

Off the top of my head, you could also probably use the Date module to assign dates to nodes and use Views to select the node whose date equals "today." This will of course require you to manually set the node you want to display on each day, but that might be what some people want.

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: