1
ukandrewf
quotes module
  • 2004/2/23 19:59

  • ukandrewf

  • Friend of XOOPS

  • Posts: 198

  • Since: 2002/12/2


I need a module which rotates quotes - showing a different one on each load - is there such a thing for XOOPS 2?

thanks

2
Dave_L
Re: quotes module
  • 2004/2/23 20:10

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


One way is to put this in a custom block (Content Type = PHP Script):

$quotes = array(
   
'here is one quote',
   
'here's a second one',
   '
this is the last quote',
);

echo $quotes[mt_rand(0, count($quotes) - 1)];

3
ukandrewf
Re: quotes module
  • 2004/2/24 11:56

  • ukandrewf

  • Friend of XOOPS

  • Posts: 198

  • Since: 2002/12/2


I'm a novice to this bit - i notice you \'s to make the ' be ignored for php purposes but what if i want to use html/bold etc as in the two quotes below...

'many thanks to you [Luiz] and Marco for treating me so well. <i>I feel fantastic and I think my life has even got better because of the way I now look and the compliments I have been paid. I feel fifteen years younger!'</i>
<BR><b><A href=http://www.url.com>Caroline - Hastings. Feb 04</a></b> Covent Garden Salon IHR

<p><I>'The team was very friendly and in whole it was a great atmosphere....and quiet an experience.'
<br>'Kriss did a great job, ... I am very satisfied with it! Truly!'</I>
<br><b>- Angelique (Jan 04 about Soho)</b>

4
kahumbu
Re: quotes module
  • 2004/2/24 13:59

  • kahumbu

  • Documentation Writer

  • Posts: 277

  • Since: 2003/8/23


There is a Random Quotes module that does what you want. Just do a Search for Random Quotes.

5
Dave_L
Re: quotes module
  • 2004/2/24 14:24

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Quote:
I'm a novice to this bit - i notice you \'s to make the ' be ignored for php purposes but what if i want to use html/bold etc as in the two quotes below...


In a single-quoted string, only the characters ' and \ need to be escaped with a \. HTML tags would work as desired.

But maybe the Random Quotes module would be better for your purposes. I'm not familiar with it.

6
ukandrewf
Re: quotes module
  • 2004/2/24 15:30

  • ukandrewf

  • Friend of XOOPS

  • Posts: 198

  • Since: 2002/12/2


i've installed random quotes module 1.0.1 but it appears that the quotes aren't rotating any ideas?

thanks

Andrew

7
El_Jordo
Re: quotes module
  • 2004/2/24 15:45

  • El_Jordo

  • Just popping in

  • Posts: 64

  • Since: 2003/4/23


I've tried many times to get the Random Quotes module to work, but it shows the first quote in the list 9 out of 10 times in my experience. It needs some work.

8
Dave_L
Re: quotes module
  • 2004/2/24 16:00

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


If you're in a hurry, and want to go back to my approach:

$quotes = array();

$quotes[] = '
   '
many thanks to you [Luiz] and Marco for treating me so well. <i>I feel fantastic and I think my life has even got better because of the way I now look and the compliments I have been paidI feel fifteen years younger!'</i>
   <BR><b><A href='
http://www.url.com/'>Caroline - Hastings. Feb 04</a></b> Covent Garden Salon IHR
';

$quotes[] = '
   
<p><I>'The team was very friendly and in whole it was a great atmosphere....and quiet an experience.'
   
<br>'Kriss did a great job, ... I am very satisfied with it! Truly!'</I>
   <
br><b>- Angelique (Jan 04 about Soho)</b>
';

echo $quotes[mt_rand(0, count($quotes) - 1)];


You could also use double quotes " to avoid having to escape the quoted quotes.

P.S. The [ code ] tag messed up the text that I pasted here somewhat, and it might need tweaking, but it illustrates the idea.

9
hsalazar
Re: quotes module
  • 2004/2/24 16:15

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


I thought this thing about random quotes was already solved...

Well, since it seems I was wrong, here are two ideas:

1) Check the first user contribute note here. It deals with rand() generating the same number over and over again.

2) You might want to try editing the random_quote_show function contained in the file random_quote.php in your module so it reads like this:
Quote:

function random_quote_show() {
global $xoopsDB;
$block = array();
$result = $xoopsDB -> query("SELECT count(*) from ".$xoopsDB -> prefix('citas'));
list($totalquotes) = $xoopsDB -> fetchRow($result);
$show = rand (1, $totalquotes);
$result2 = $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix("citas")." WHERE id=".$show);
list($texto, $autor)= $xoopsDB->fetchRow($result);
$block['texto']=$texto;
$block['autor']=$autor;
return $block;
}

The code is a bit longer than the original, but might work better.

Cheers.

10
ukandrewf
Re: quotes module
  • 2004/2/25 14:05

  • ukandrewf

  • Friend of XOOPS

  • Posts: 198

  • Since: 2002/12/2


thanks that helped :)

Login

Who's Online

223 user(s) are online (144 user(s) are browsing Support Forums)


Members: 0


Guests: 223


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits