Gossamer Forum
Quote Reply
new links
how to grab all the new links form the child categories and put them in the root category page?
Quote Reply
Re: [xpert] new links In reply to
If I understand you correctly, you want to put all the new links on the front page? If that is what you want, let me know, and I'll knock up a global for ya ;)

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] new links In reply to
No, i want to pull the new links from each sub_category and display it on it's root category pages!
Quote Reply
Re: [xpert] new links In reply to
Do you mean a global that returns all the new links in a given category tree? That is something I have asked for in the past.
Quote Reply
Re: [nt6] new links In reply to
Pull all the new links from those subcategories and display them in their root category. i don't understand what your meant by category tree way, though i assume it should be similar to what i want. hope somebody can help!

- root cat (new links of all its' subcategories here)

-sub of root

-sub2 of root

-sub3 of root
Quote Reply
Re: [xpert] new links In reply to
There is a similar thread here:

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

Note that this global is not well written - but it does the job. You may be able to use this global to tidy it up:

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

Hope that helps,
Laura.
The UK High Street
Quote Reply
Re: [afinlr] new links In reply to
Hey Laura,

I got the following global working, i need it that this line will only appear if there's new link listings, since right it appears even if there's no new listings!

my $output = qq~<b>The newest Links in this category and the following subcategories:</b>~;

Can you help?

sub {
my $tags = shift;
my @list;
my $cat_id = $tags->{'ID'};

my $link_db = $DB->table('Links','CatLinks','Category');
my $sth = $link_db->select ( { CategoryID => $cat_id, isValidated => 'Yes', isNew =>'Yes' });
$link_db->select_options ("ORDER BY Add_Date");

my $cat_db = $DB->table('Category');
my $sth2 = $cat_db->select ( ['ID'],{ FatherID => $cat_id });

while (my $link = $sth->fetchrow_hashref) {
push @list, $link;
}

while (my ($child_id) = $sth2->fetchrow_array) {
my $sth3 = $link_db->select ( { CategoryID => $child_id, isValidated => 'Yes', isNew => 'Yes' });

while (my $link2 = $sth3->fetchrow_hashref) {
push @list, $link2;
}
}

# Sort
my %tmp_sort;
my @new_list;

for(my $i = 0; $i < $#list; $i++) {
my $key = ${$list[$i]}{'Add_Date'};
$key =~ s/-//g;
$key.= '0';

while($tmp_sort{$key}) {
$key += 1;
}
$tmp_sort{$key} = $list[$i];
}

my $new_cnt = 0;

foreach my $tmp_key (sort {$b <=> $a} (keys(%tmp_sort))) {

if ($new_cnt < 5) {
$new_list[$new_cnt] = $tmp_sort{$tmp_key};
$new_cnt++;
}
}

@list = @new_list;

my $output = qq~<b>The newest Links in this category and the following subcategories:</b>~;

foreach my $link (@new_list) {

# Set the category url
my $url = $cat_db->as_url($link->{'Full_Name'});

# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$link->{'LinkID'}$CFG->{build_extension}";

$output .= qq~<li><a href="$CFG->{build_root_url}/$url/">$link->{'Name'}</a> | $link->{'Add_Date'}<br><a href="$detailed_url">$link->{'Title'}</a></li>~;
}

return $output;

}

Last edited by:

xpert: Sep 18, 2002, 5:34 PM
Quote Reply
Re: [xpert] new links In reply to
Also any ideas on hwo to make this global only display on the root category pages and not its subcats?
Quote Reply
Re: [xpert] new links In reply to
Hi,

I've had a go at tidying it up a bit:

sub {
my $tags = shift;
my ($all_ids,@list,$output);
my $cat_id = $tags->{'ID'};
$all_ids = $DB->table('Category')->children($cat_id);
push @$all_ids, $cat_id;
my $link_db = $DB->table('Links','CatLinks','Category');
$link_db->select_options ("ORDER BY Add_Date DESC LIMIT 5");
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','isNew','=','Yes','CategoryID', 'IN', \@$all_ids);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
push @list, $link;
}

my $root = $DB->table('Category')->count({ID => $cat_id, FatherID => 0});
if ((@list) and ($root > 0) ) {
$output = qq~<b>The newest Links in this category and the following subcategories:</b>~;
foreach my $link (@list) {
# Set the category url
my $url = $DB->table('Category')->as_url($link->{'Full_Name'});
# Set the detailed_url
my $detailed_url = "$CFG->{build_detail_url}/$link->{'LinkID'}$CFG->{build_extension}";
$output .= qq~<li><a href="$CFG->{build_root_url}/$url/">$link->{'Name'}</a> | $link->{'Add_Date'}<br><a href="$detailed_url">$link->{'Title'}</a></li>~;
}
}
return $output;

}
The UK High Street
Quote Reply
Re: [afinlr] new links In reply to
Thank you a million Laura, the global now works fine as expected!

Angelic