Generate random messages or user tips

So many software products give you those startup tips, so I decided I wanted to give users usage tips that show at random in a block. You could of course show any random message, e.g. thought of the day, featured link ....

<?php
 
global $user;
 
$tips = array(
   
'blah blah blah',
   
'blah de blah',
   
'You can embed an <a href="http://www.example.com">HTML link</a> in a message',
   
'Direct users to their own <a href="http://www.example.com?q=user/'.$user->uid.'">"account"</a>',
    );

  return
$tips[rand(0,count($tips)-1)];
?>

Go to administer>>blocks, click on "add block", give it a title, then paste this code in the body. Edit it to your own messages and save.

If the messages change often you probably want something fancier that reads the messages from a database, but this works for me. I have 16 tips right now and there will be more. It will be a long time before a user notices and reads all 16.

 
 

Drupal is a registered trademark of Dries Buytaert.