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

Products: Gossamer Links: Development, Plugins and Globals: Random Global Questions: Edit Log

Here is the list of edits for this post
Random Global Questions
I had a long long thread http://www.gossamer-threads.com/...rum.cgi?post=174933; going a while back, but I thought I would start fresh and hopefully it can be easier to follow. I really want to add fuctionality, if someone here can write it.

I have a really nice global that Alex, Paul and Pugdog helped me figure out. (I hope I didn't miss anyone!) What it does is
1) allow you to have random links from a particlar category show up
2) not have any duplicates of those links show at the same time.
3) It creates dynamic (refreshing) random links on static pages.

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

Then I create a template called:
random.html with the following in it

<%loop Random_Loop%>
<div align="left"><a href="<%build_root_url%>/Detailed/<%ID%>.html"><b>
<a href="<%build_root_url%>/Detailed/<%ID%>.html"> more</A></%body_font%> <br>

I then call that template within the category template like this:
<!--#include virtual="/cgi-bin/dir/page.cgi?p=random&Random_CatID=<%ID%>"-->
<!--#include virtual="/cgi-bin/dir/page.cgi?p=random&Random_CatID=9"-->

What I want to change
I would love to make it be able to choose from any of the subcats within a category. What happens is that I have:

Category 1
-subcat a
-subcat b
-subcat c

I want to be able to use <!--#include virtual="/cgi-bin/dir/page.cgi?p=random&Random_CatID=<%ID%>"--> and have it pull links from within subcat a,b and c when I put the above ssi in Category 1. (many times there are no links in Category 1)

Can this work? How? Can you explain it?

Last edited by:

Evoir: Aug 2, 2002, 4:36 PM

Edit Log: