1
BradM
Req: random quote in replace of banners?
  • 2003/12/17 6:56

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Hi,

I don't use banners on my site, so I'd like to throw a random quote up there instead (using the Random Quotes module -- the random quote usually appears in a block). I tried simply adding <{$random_quote_show}> in theme.html, however that produced nothing.

Any ideas or suggestions?


Brad

2
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 9:22

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


NM, I managed to figure it out. :)


3
hsalazar
Re: Req: random quote in replace of banners?
  • 2003/12/17 16:29

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Hey, BradM:

Would you care to share your findings with the community?

Cheers.

4
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 17:10

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Yep! Now that I've had some sleep my post might make sense!

The following hack will allow you to display the output of the random quote module (found at ModsCentral) in the banner area of your site (but I'm sure it can be used to show it wherever you like)... basically it takes the random quote out of a block. It's actually more of a core hack than theme hack I guess.

Since I don't use banners at my site, I've used that area to build the quote, but I'm sure it can be hacked to show both.

In header.php you'll find this code, starting around line 79:
// show banner?
if ($xoopsConfig['banners'] == 1) {
    
$xoopsTpl->assign('xoops_banner'xoops_getbanner());
} else {
    
$xoopsTpl->assign('xoops_banner'' ');
}

Since I have banners off, I modified the else condition as follows:
} else {
    
$block = array();
        
$result $xoopsDB->query("SELECT count(*) FROM ".$xoopsDB->prefix("citas"));
    list(
$total_rows) = $xoopsDB->fetchRow($result);
        
$x rand(1,$total_rows);
        
$result $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix("citas")." WHERE id=".$x);
        list(
$texto$autor)= $xoopsDB->fetchRow($result);
    if (
$autor) { $autor2 " -- ".$autor; }
    else { 
$autor2 ""; }
    
$xoopsTpl->assign('xoops_banner'"$texto $autor2");
}

The above will then spit out the random quote, with formatting based on td#headerbanner in your theme's css file. It will look something like this:

Have no fear of perfection; you'll never reach it. -- Salvador Dali

if ($autor) { $autor2 " -- ".$autor; }
else { 
$autor2 ""; }

You might be wondering why I have included the above. I use the quote module not only for quotes, but also for small bits of information (for example, the date that a particular event occured). When one of these is displayed, there really isn't an author (autor) associated with it. Therefore I don't want the -- to be displayed after the quote/texto information.

Also, if you want to change the formatting of the quote or author, the easiest way to do this is modify $xoopsTpl->assign('xoops_banner', "$texto $autor2");, for example:

$xoopsTpl->assign('xoops_banner', "$texto
$autor2");


I'm pretty new to php, so there might be a better way to do this, but the above seems to work!


Brad

5
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 19:18

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


... and if you want to keep banners, just do the following:

Take the code out of the else statement, and put it on its own in the same area.

Change the last line to this:
$xoopsTpl->assign('xoops_randomquote', "$texto $autor2");

And then within your theme.html file, put <{$xoops_randomquote}> wherever you want the quote to appear.


Brad

6
hsalazar
Re: Req: random quote in replace of banners?
  • 2003/12/18 0:45

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


BradM:

Thanks! This is what the essence of the XOOPS community is about: we all learn and share.

Cheers.

7
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/29 0:51

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


I've since discovered that using the $result variable here could mess up other modules (such as the weBlog). So you should use a unique variable, such as $thequote instead of $result.


Brad

Login

Who's Online

403 user(s) are online (285 user(s) are browsing Support Forums)


Members: 0


Guests: 403


more...

Donat-O-Meter

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

Latest GitHub Commits