Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 10:27 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!
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!
16
18
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:
]
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):
/*
* 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
]
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
11
10
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.
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.
14
13
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?
except sometimes, a blank slogan comes up...
why?
and...does the sid of each slogan matter?
9
14
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..?)
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..?)
16
15
Quote
All times are EST. The time is now 10:27 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