I need a global that can be placed on home page and accepts the category id as an input, and returns back the immediate cat/subcat name only and the links in it:
Something like this:
<%show_cat('44')%>
which will return only a link to subcat
Nissan Pathfinder
- Nissan 1996 new car....
- Nissan Pathfinder 2001 with new tires...
- link3
- link4
from
CARS > Japaniese > Nissan > Nissan Pathfinder
thanks for your help
Mark
or how can I enhance this global by webmaster33 to display all links for the category (not the new ones only) and display also the immediate cat name:
Let me post the full global code, containing changes of the thread.
Global task: Display the latest the new 10 links only of a single category.
Global code:
my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY Add_Date DESC Limit 10');
my $sth = $db_obj->select (['Links.*'], GT::SQL::Condition->new(
['CategoryID', 'IN', $all_ids],
['isValidated', '=', 'Yes', 'isNew', '=', 'Yes'])
);
my $output = qq~<br><hr>~;
while (my $link = $sth->fetchrow_hashref) {
$link->{'category_url'} = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Global Usage:
<%new_links_of_category('1234')%>
1234 = category id of specific category
I also posted the code to Links SQL/Globals resources page.
It would be good idea to have more & more globals posted into the resource page above...
Laura, could you also post some globals to the Links SQL/Globals resources page?
Best regards,
Webmaster33
Something like this:
<%show_cat('44')%>
which will return only a link to subcat
Nissan Pathfinder
- Nissan 1996 new car....
- Nissan Pathfinder 2001 with new tires...
- link3
- link4
from
CARS > Japaniese > Nissan > Nissan Pathfinder
thanks for your help
Mark
or how can I enhance this global by webmaster33 to display all links for the category (not the new ones only) and display also the immediate cat name:
Code:
Let me post the full global code, containing changes of the thread.
Global task: Display the latest the new 10 links only of a single category.
Global code:
Code:
sub { my $cat = shift;
my $all_ids = $DB->table('Category')->children($cat);
push @$all_ids, $cat;
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ('ORDER BY Add_Date DESC Limit 10');
my $sth = $db_obj->select (['Links.*'], GT::SQL::Condition->new(
['CategoryID', 'IN', $all_ids],
['isValidated', '=', 'Yes', 'isNew', '=', 'Yes'])
);
my $output = qq~<br><hr>~;
while (my $link = $sth->fetchrow_hashref) {
$link->{'category_url'} = $CFG->{build_root_url}."/".$link->{'Full_Name'}."/";
$link->{'detailed_url'} = "$CFG->{build_detail_url}/$link->{'ID'}$CFG->{build_extension}";
$output .= Links::SiteHTML::display('link', $link);
}
return $output;
}
Global Usage:
<%new_links_of_category('1234')%>
1234 = category id of specific category
I also posted the code to Links SQL/Globals resources page.
It would be good idea to have more & more globals posted into the resource page above...
Laura, could you also post some globals to the Links SQL/Globals resources page?
Best regards,
Webmaster33