rfscholl Posted January 3, 2009 Posted January 3, 2009 I would like to have an infobox that randomly displays one of a list of testimonials. It could display a different one on every page load, or just every few seconds. I did not see one in contribs. Does anyone have an idea on how to make this happen? Thanks!!
roya.k Posted January 3, 2009 Posted January 3, 2009 1. create a new php file called random.php or anything you want. <?php /* random.php */ function get_my_rand_string() { /* select rand in database or */ $tab = array( "Love me tender", "Love me sweet", "Never let me go", "You have made my life complete", "And I love you so" ); $nb = rand(0, 4); /* 4+1 = total nb of strings*/ return $tab[$nb]; } ?> <!-- Rand //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => 'Your Title'); new infoBoxHeading($info_box_contents, true, false); $rand_string = get_my_rand_string(); $info_box_contents = array(); $info_box_contents[] = array('text' => $rand_string); new infoBox($info_box_contents); ?> </td> </tr> <!-- Rand_eof //--> 2. Upload random.php into /includes/boxes/ 3. add the following line of code to /includes/column_left.php or /includes/column_right.php require(DIR_WS_BOXES . 'random.php'); Open source n'est pas un échange à sens unique ... La plupart du temps un simple merci ou quelques mots d'encouragement suffisent...
ianric Posted January 3, 2009 Posted January 3, 2009 1. create a new php file called random.php or anything you want. <?php /* random.php */ function get_my_rand_string() { /* select rand in database or */ $tab = array( "Love me tender", "Love me sweet", "Never let me go", "You have made my life complete", "And I love you so" ); $nb = rand(0, 4); /* 4+1 = total nb of strings*/ return $tab[$nb]; } ?> <!-- Rand //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => 'Your Title'); new infoBoxHeading($info_box_contents, true, false); $rand_string = get_my_rand_string(); $info_box_contents = array(); $info_box_contents[] = array('text' => $rand_string); new infoBox($info_box_contents); ?> </td> </tr> <!-- Rand_eof //--> 2. Upload random.php into /includes/boxes/ 3. add the following line of code to /includes/column_left.php or /includes/column_right.php require(DIR_WS_BOXES . 'random.php'); Hi There's 2 testimonial contribs in the contribs area, search for "testimonial" without quotes. The one i'm using is this HTH ian
rfscholl Posted January 4, 2009 Author Posted January 4, 2009 Thanks for the help. The code got me going. Thanks again!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.