Welcome to Geeklog Wednesday, August 21 2019 @ 03:03 am EDT

Geeklog Forums

Random quote in header.thml?


Status: offline

xardoz

Forum User
Regular Poster
Registered: 24/02/04
Posts: 98
Hi,
I'm using a theme based on apv_aeon, and I want to have a random quote appear in the header every time a page loads.
I've tried various javascripts for this, but the quotes never show up.
The pages don't seem to generate any errors, BTW.
Is this possible with Geeklog, has anyone done it and if so, does anyone have some code I could use?
Thanks!

Status: offline

tomw

Forum User
Full Member
Registered: 12/08/02
Posts: 300
You mean like at the Pigstye ? All I did there was create a database table to hold the random quotes like thus:

]
PHP Formatted Code
CREATE TABLE gl_slogan (
  slogan varchar(255) NOT NULL default '',
  sid int(10) NOT NULL auto_increment,
  PRIMARY KEY  (sid)
) TYPE=MyISAM;

 


and add this code to Geeklog (say in lib_custom.php):

PHP Formatted Code
$_CONF['site_slogan'] = get_slogan();

/*
* Get Slogan from DB
*/

function get_slogan() {
    $rst = DB_query("SELECT * from gl_slogan");
    $nrows = DB_numRows($rst);
    $nm = rand(1,$nrows);
    for ($i=1;$i<$nm;$i++) {
        $A = DB_fetchArray($rst);
    }
    return $A['slogan'];
}

 


I assume you can get the slogans in the DB.

TomW

Status: offline

xardoz

Forum User
Regular Poster
Registered: 24/02/04
Posts: 98
happy
Exactly!


Thanks!


spirshi

Anonymous
...and if you cant get slogans in the db??


where can i run that code to make the db?
i tried just making it through 'phpmyadmin'

i'm new at this and would appreciate any help.

spirshi

Anonymous
well...i got it to work.
except sometimes, a blank slogan comes up...
why?

and...does the sid of each slogan matter?

Status: offline

xardoz

Forum User
Regular Poster
Registered: 24/02/04
Posts: 98
It might be that you've got a quotation mark problem. I had to enter my slogans directly via phpMyAdmin, and that solved the problem for me.

spirshi

Anonymous
sorry for all these msgs...

just found out that whilst it sometimes shows up a blank slogan, it also never shows whatever the last slogan i have in the database is.

i know this problem is related. probably sometime to do with zero based counting? (ie starting at zero instead of 1..?)

Status: offline

spirshi

Forum User
Newbie
Registered: 14/04/04
Posts: 8
yah, i entered all my slogans through phpmyadmin.

regardless, the last one i enter never comes up.
and sometimes no slogan comes up.
i think the problem is related.

All times are EDT. The time is now 03:03 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content