Welcome to Geeklog, Anonymous Monday, April 29 2024 @ 10:18 pm EDT

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
 Quote

Status: offline

geKow

Forum User
Full Member
Registered: 01/12/03
Posts: 445
hmmm.... 103 views, but no answer? Confused
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
This works nicely:
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;
}

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

Status: offline

geKow

Forum User
Full Member
Registered: 01/12/03
Posts: 445
Big Celebration you are simply great... not only because this one, but I allready find lots of your code snippets extremly usefull. Thanks.

geKow
 Quote

All times are EDT. The time is now 10:18 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