Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 09:17 am EST
Geeklog Forums
Req: Random Link
Status: offline
geKow
Forum User
Full Member
Registered: 01/12/03
Posts: 445
Sorry if that allready exists....
I would like to have a block wich shows a random link from my collection (including the desription and may be the link category) just like the random image block.
Would that be possible?
geKow
I would like to have a block wich shows a random link from my collection (including the desription and may be the link category) just like the random image block.
Would that be possible?
geKow
13
11
Quote
Status: Banned
machinari
Forum User
Full Member
Registered: 03/22/04
Posts: 1512
This works nicely:
{
global $_TABLES;
$retval = '';
$result = DB_query ("SELECT lid,category,url,title,description FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY RAND() LIMIT 1");
$nrows = DB_numRows ($result);
if ($nrows > 0) {
$A = DB_fetchArray ($result);
$url = COM_buildUrl ($_CONF['site_url']
. '/portal.php?what=link&item=' . $A['lid']);
$retval .= '<p>Category: ' . stripslashes($A['category']) . '</p>' . LB;
$retval .= '<p><a href="' . $url . '" title="' . $A['url'] . '">'
. stripslashes($A['title']) . '</a></p>' . LB;
$retval .= '<p>' . stripslashes($A['description']) . '</p>' . LB;
}
return $retval;
}
Text Formatted Code
function phpblock_randomLink(){
global $_TABLES;
$retval = '';
$result = DB_query ("SELECT lid,category,url,title,description FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL ('AND') . " ORDER BY RAND() LIMIT 1");
$nrows = DB_numRows ($result);
if ($nrows > 0) {
$A = DB_fetchArray ($result);
$url = COM_buildUrl ($_CONF['site_url']
. '/portal.php?what=link&item=' . $A['lid']);
$retval .= '<p>Category: ' . stripslashes($A['category']) . '</p>' . LB;
$retval .= '<p><a href="' . $url . '" title="' . $A['url'] . '">'
. stripslashes($A['title']) . '</a></p>' . LB;
$retval .= '<p>' . stripslashes($A['description']) . '</p>' . LB;
}
return $retval;
}
10
11
Quote
Status: Banned
machinari
Forum User
Full Member
Registered: 03/22/04
Posts: 1512
btw, I doubt that it will works once 1.3.12 come out as Trinity and Tokyoahead (i think) have turned the links bit into a plugin. A minor adjustment is all it would take I'm sure.
9
8
Quote
All times are EST. The time is now 09:17 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