Welcome to Geeklog, Anonymous Thursday, February 02 2023 @ 11:08 pm EST

Geeklog Forums

Random quote in header.thml?


Status: offline

xardoz

Forum User
Regular Poster
Registered: 02/24/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!
 Quote

Status: offline

tomw

Forum User
Full Member
Registered: 08/12/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:

]
Text 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):

Text 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
 Quote

Status: offline

xardoz

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


Thanks!

 Quote

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.
 Quote

spirshi

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

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

Status: offline

xardoz

Forum User
Regular Poster
Registered: 02/24/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.
 Quote

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..?)
 Quote

Status: offline

spirshi

Forum User
Newbie
Registered: 04/14/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.
 Quote

All times are EST. The time is now 11:08 pm.

  • 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