Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Random link question

Quote Reply
Random link question
Does the random link script check to see if there is, in fact, a URL for the listing?

For example, if one is left blank (http://) will it still be called by the random link script?

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Random link question In reply to
Not as far as I know. You could try editing /admin/Links/Jump.pm, so instead of;

Code:
# If we are chosing a random link, then get the total and go to one at random.
if (lc $id eq "random") {
my $total = $db->count(VIEWABLE);
my $offset = int rand $total;
$db->select_options("LIMIT 1 OFFSET $offset");
my $sth = $db->select(qw/ID URL/ => VIEWABLE);
($id, $goto) = $sth->fetchrow_array;
}

...you have;

Code:
# If we are chosing a random link, then get the total and go to one at random.
if (lc $id eq "random") {
my $cond = GT::SQL::Condition->new('URL','LIKE','http://%');
$db->select_options("LIMIT 1","ORDER BY RAND(NOW)");
my $sth = $db->select(qw/ID URL/ => VIEWABLE => $cond);
($id, $goto) = $sth->fetchrow_array;
}

Please be sure to back the original code though, as it *may* not work (its not tested).

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Random link question In reply to
Thanks Andy, I'll give it a spin when I get the chance (on my current install it'd be hard to test with the thousands of links).

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Random link question In reply to
Heads up to GT.

Any chance this can be made part of the default Links SQL?

cdkrg

Able2Know :: Ajooja Directory
Quote Reply
Re: [cdkrg] Random link question In reply to
In Reply To:
Heads up to GT.

Any chance this can be made part of the default Links SQL?

Seeing this from GT's point of view.. they need to be sure that the code they provide is compatible with MySQL, MSQL, MSSQL, PostGres, etc. I believe only a couple (possibly just MySQL) of these actually support the RAND() function.

Hope that helps :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Random link question In reply to
Good point, but whatever randomizing functions they do use shouldn't need to be altered, just the check to see if there is a URL needs to be added.

Anywho, I hope they do, hacking at the code makes updates a pain and i try to limit my hardcode modification.

cdkrg

Able2Know :: Ajooja Directory