Posted on: 05/21/04 09:57am
By: xardoz
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!
Random quote in header.thml?
Posted on: 05/21/04 11:39am
By: tomw
You mean like at
the Pigstye[*1] ? All I did there was create a database table to hold the random quotes like thus:
]
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):
$_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
Random quote in header.thml?
Posted on: 05/21/04 12:40pm
By: xardoz
Exactly!
Thanks!
Random quote in header.thml?
Posted on: 06/14/04 01:23pm
By: Anonymous (spirshi)
...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.
Random quote in header.thml?
Posted on: 06/14/04 02:44pm
By: Anonymous (spirshi)
well...i got it to work.
except sometimes, a blank slogan comes up...
why?
and...does the sid of each slogan matter?
Random quote in header.thml?
Posted on: 06/14/04 02:50pm
By: xardoz
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.
Random quote in header.thml?
Posted on: 06/14/04 02:52pm
By: Anonymous (spirshi)
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..?)
Random quote in header.thml?
Posted on: 06/14/04 11:15pm
By: spirshi
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.