Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

random links from a specific category on the detailed page

Quote Reply
random links from a specific category on the detailed page
Hi

I have the following global

sub {
my $tags = shift;
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 5;
my (@output, $sth); $link_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
if ($cat_id) {
$sth = $link_db->select ( { CategoryID => $cat_id, IsValidated => 'Yes'});
}
else {
$sth = $link_db->select(IsValidated => 'Yes');
}
while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}
return { Random_Loop => \@output }
}

that I call from the detailed template with

<%set Random_CatID = $CategoryID%>
<%random_links%>
<%loop Random_Loop%>
<li><%Title%></li>
<%endloop%>


It was working fine when I used LSQL 2.1.2 but it is not working anymore since I have upgraded to LSQL 2.2.0

I seems that $CategoryID is not recognised in the detailed template, so the value is not passed to the global...

Any Idea ????

txs FMP
Quote Reply
Re: [fmp] random links from a specific category on the detailed page In reply to
Hello,

This works for me.

http://www.gossamer-threads.com/...i?post=262268#262268

Mick
Quote Reply
Re: [mick31] random links from a specific category on the detailed page In reply to
Hi

txs for your answer

it also work for me if I use use it from the category template... but it dosn't if I use it in the detailed page...

<%set Random_CatID = $CategoryID%>
Is is just that $CategoryID is not recognised...

The global work fine if hardcode the Id of the category : <%set Random_CatID = 7%> works fine

I don't understand why $CategoryID is not recognised... ???Unsure

any clue ??

FMP
Quote Reply
Re: [fmp] random links from a specific category on the detailed page In reply to
 
Probably, such variant will help you:


<%set Random_CatID = $ID%>

_________________________________________________________________________________________________________________
Web directory and search engine | Dirlist.net Directory - Add your link today.
Quote Reply
Re: [Bigpat] random links from a specific category on the detailed page In reply to
Hi Bigpat

If I insert <%set Random_CatID = $ID%> from the detailed page, it will pass the Link ID... and I want to pass the Id of the category the link belong to

Any idea???

txs for your help
FMP
Quote Reply
Re: [fmp] random links from a specific category on the detailed page In reply to
If it was working in a previous version then I think you must have been using a global to get the CategoryID. There isn't a value for CategoryID on the detail page because a link can be in several categories.

You need a global that reads in the LinkID, looks it up in the CatLinks table and returns a CategoryID.
Quote Reply
Re: [afinlr] random links from a specific category on the detailed page In reply to
txs for your help

I 've tried myself but but didn't succeed... (I'm quite a newbie in perl Unsure) How can I alter my global to get the IDs of the the categories the link belongs to ??? and then to display 5 random links in the detailed page... Regards FMPWink
Quote Reply
Re: [fmp] random links from a specific category on the detailed page In reply to
   
Smile here is the thread that helped me to resolve my problem
http://www.gossamer-threads.com/...i?post=276562#276562

FMP