How I can get list in a category of all related links, I mean the category have some Related category and I need the link of the Related categories.
Aug 4, 2009, 3:51 AM
Veteran / Moderator (17366 posts)
Aug 4, 2009, 3:51 AM
Post #2 of 15
Views: 1010
You mean you want to get the related categories, and then "grab" the links that are in that category, and show them on category.html too?
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 4, 2009, 8:46 AM
Veteran / Moderator (17366 posts)
Aug 4, 2009, 8:46 AM
Post #4 of 15
Views: 993
Ok, took a while to get right (I thought we could just get a list of values as an arrayref direct from $DB, but seems we can't - so had to do it a more long winded way.
Anyhow, this should work:
get_links_from_related_cats
my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( ['RelatedID'], { CategoryID => $cat_id } );
my $cats;
while (my $hit = $sth->fetchrow_hashref) {
push @$cats, "$hit->{RelatedID}";
}
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ("ORDER BY " .$CFG->{build_sort_order_category});
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $cats);
my $cond2 = GT::SQL::Condition->new('isNew','=','Yes','isValidated','=','Yes');
my $sth = $db_obj->select (['Links.*'], $cond, $cond2 ) || die $GT::SQL::error;
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} ); }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @loop, $hit;
}
return { related_cat_links => \@loop }
}
<%if related_cat_links.length%>
<%loop related_cat_links%>
<%include link.html%>
<%endloop%>
<%endif%>
Obviously this will only work in category.html.
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Anyhow, this should work:
get_links_from_related_cats
Code:
sub { my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( ['RelatedID'], { CategoryID => $cat_id } );
my $cats;
while (my $hit = $sth->fetchrow_hashref) {
push @$cats, "$hit->{RelatedID}";
}
my $db_obj = $DB->table('Links','CatLinks','Category');
$db_obj->select_options ("ORDER BY " .$CFG->{build_sort_order_category});
my $cond = GT::SQL::Condition->new('CategoryID', 'IN', $cats);
my $cond2 = GT::SQL::Condition->new('isNew','=','Yes','isValidated','=','Yes');
my $sth = $db_obj->select (['Links.*'], $cond, $cond2 ) || die $GT::SQL::error;
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_detail_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} ); }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @loop, $hit;
}
return { related_cat_links => \@loop }
}
Code:
<%get_links_from_related_cats($ID)%> <%if related_cat_links.length%>
<%loop related_cat_links%>
<%include link.html%>
<%endloop%>
<%endif%>
Obviously this will only work in category.html.
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 5, 2009, 1:52 AM
Veteran / Moderator (17366 posts)
Aug 5, 2009, 1:52 AM
Post #6 of 15
Views: 974
Glad it worked. To get a list of the categories that are related to the current category, you would do something like (untested)
work_out_related_cats
my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( { CategoryID => $cat_id } );
my @related_cats;
while (my $hit = $sth->fetchrow_hashref) {
my $cat = $DB->table('Category')->select( { ID => $hit->{RelationID} } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
if (length $hit->{RelationName} > 0) {
$cat->{Name} = $hit->{RelationName};
}
push @related_cats, $cat;
}
return { related_cat_loop => \@related_cats };
}
Then in category.html:
<%if related_cat_loop.length%>
<%loop related_cat_loop%>
<a href="<%URL%>"><%Name%></a> <br />
<%endloop%>
<%endif%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
work_out_related_cats
Code:
sub { my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( { CategoryID => $cat_id } );
my @related_cats;
while (my $hit = $sth->fetchrow_hashref) {
my $cat = $DB->table('Category')->select( { ID => $hit->{RelationID} } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
if (length $hit->{RelationName} > 0) {
$cat->{Name} = $hit->{RelationName};
}
push @related_cats, $cat;
}
return { related_cat_loop => \@related_cats };
}
Then in category.html:
Code:
<%work_out_related_cats($ID)%> <%if related_cat_loop.length%>
<%loop related_cat_loop%>
<a href="<%URL%>"><%Name%></a> <br />
<%endloop%>
<%endif%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 5, 2009, 2:09 AM
Veteran / Moderator (17366 posts)
Aug 5, 2009, 2:09 AM
Post #8 of 15
Views: 967
Sorry, my mistake - please try the edited versions above (I made a few mess ups in the last version =))
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 5, 2009, 2:43 AM
Veteran / Moderator (17366 posts)
Aug 5, 2009, 2:43 AM
Post #10 of 15
Views: 960
Oops, please change:
to
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Code:
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $hit->{Full_Name} ) . "/" . $CFG->{build_index};to
Code:
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 5, 2009, 5:12 AM
Veteran / Moderator (17366 posts)
Aug 5, 2009, 5:12 AM
Post #12 of 15
Views: 944
What do you see when you put:
<%DUMP related_cat_loop%>
?
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
<%DUMP related_cat_loop%>
?
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Aug 5, 2009, 5:19 AM
Veteran / Moderator (17366 posts)
Aug 5, 2009, 5:19 AM
Post #14 of 15
Views: 939
Ah, I see the problem - try this:
my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( { CategoryID => $cat_id } );
my @related_cats;
while (my $hit = $sth->fetchrow_hashref) {
my $cat = $DB->table('Category')->select( { ID => $hit->{RelatedID} } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
if (length $hit->{RelationName} > 0) {
$cat->{Name} = $hit->{RelationName};
}
push @related_cats, $cat;
}
return { related_cat_loop => \@related_cats };
}
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Code:
sub { my $cat_id = $_[0];
my $sth = $DB->table("CatRelations")->select( { CategoryID => $cat_id } );
my @related_cats;
while (my $hit = $sth->fetchrow_hashref) {
my $cat = $DB->table('Category')->select( { ID => $hit->{RelatedID} } )->fetchrow_hashref;
$cat->{URL} = $CFG->{build_root_url} . "/" . $DB->table('Category')->as_url( $cat->{Full_Name} ) . "/" . $CFG->{build_index};
if (length $hit->{RelationName} > 0) {
$cat->{Name} = $hit->{RelationName};
}
push @related_cats, $cat;
}
return { related_cat_loop => \@related_cats };
}
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

