how to grab all the new links form the child categories and put them in the root category page?
Sep 14, 2002, 8:17 AM
Veteran / Moderator (18436 posts)
Sep 14, 2002, 8:17 AM
Post #2 of 10
Views: 3047
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!
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!
Sep 14, 2002, 1:11 PM
User (277 posts)
Sep 14, 2002, 1:11 PM
Post #5 of 10
Views: 3016
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
- root cat (new links of all its' subcategories here)
-sub of root
-sub2 of root
-sub3 of root
Sep 16, 2002, 12:29 PM
Veteran (1921 posts)
Sep 16, 2002, 12:29 PM
Post #6 of 10
Views: 2988
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
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
Sep 18, 2002, 5:18 PM
User (277 posts)
Sep 18, 2002, 5:18 PM
Post #7 of 10
Views: 2955
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;
}
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;
}
Sep 19, 2002, 6:56 AM
Veteran (1921 posts)
Sep 19, 2002, 6:56 AM
Post #9 of 10
Views: 2915
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
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