Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Help in showing links in higher catogories

(Page 2 of 2)
> >
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Blush
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Hi Essam,

So we must create ShowSubCategoryLinks in Category Table[/url] as column??? then create a global called subcategory_links with:

sub {
my $output;
my $tags = shift;

return '' unless ($tags->{ShowSubCategoryLinks});
my $cat_id = $tags->{ID};
my $subcats = $DB->table('Category')->children($cat_id);
push @$subcats, $cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', $subcats);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
$output .= qq~<li><a href="$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}">$link->{'Title'}~;
}
return $output;
}

Le me know and thanks in advance

Antoine
Quote Reply
Re: [antoined] Help in showing links in higher catogories In reply to
Yes,

Then change the (ShowSubCategoryLinks) for each (sub)category to YES.
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Hi all,

How can I change slighly the global to have the link listed only if it match an additional criteria

eg :

I have several link types and I want the global to list only the links in subcaterories that have its additional field "link_type" equal to 1 for example

???

Thank in advance,

Fabrice
Quote Reply
Re: [fff] Help in showing links in higher catogories In reply to
If the field is in your Links table, you can just add an extra condition to the condition statement.

sub {
my $output;
my $tags = shift;

return '' unless ($tags->{ShowSubCategoryLinks});
my $cat_id = $tags->{ID};
my $subcats = $DB->table('Category')->children($cat_id);
push @$subcats, $cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', $subcats, 'link_type', '=', '1');
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
$output .= qq~<li><a href="$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}">$link->{'Title'}</a>~;
}
return $output;
}
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
thanks afinlr

that is exactly what I needed ! Smile

thanks aain

fabrice
Quote Reply
Re: [antoined] Help in showing links in higher catogories In reply to
Hi,

I did everything shown below, except I changed it to: $output .= Links::SiteHTML::display ('link', $link);

Then I went in and changed Show SubCategory Links to "YES" where appropriate.

It works fine in the categories that only have 3 categories deep, but others with more than 3 categories deep don't display ANY sub category listing at all (not even on the first levels).

Am I totally missing something here? Or what...

-Di

In Reply To:
Hi Essam,

So we must create ShowSubCategoryLinks in Category Table[/url] as column??? then create a global called subcategory_links with:

sub {
my $output;
my $tags = shift;

return '' unless ($tags->{ShowSubCategoryLinks});
my $cat_id = $tags->{ID};
my $subcats = $DB->table('Category')->children($cat_id);
push @$subcats, $cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', $subcats);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
$output .= qq~<li><a href="$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}">$link->{'Title'}~;
}
return $output;
}

Le me know and thanks in advance

Antoine
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Quote Reply
Re: Help in showing links in higher catogories In reply to
I have been using this global for the last year (for example my t-shirt category) and it is great. However, the sort order is by title and I would like it to use the sort order as defined in build_sort_order_category (i.e. Hits DESC,isPopular DESC,isNew DESC,Title). Is this possible? TIA



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
Quote Reply
Re: [IndigoClothing] Help in showing links in higher catogories In reply to
Try adding

$link_db->select_options ("ORDER BY $CFG->{build_sort_order_search_cat}");
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Thanks Laura - not sure where to add it - tried a few places and got errors - which line should it gone on? My global currently is:

Code:
sub {
my $output;
my $tags = shift;

return '' unless ($tags->{ShowSubCategoryLinks});
my $cat_id = $tags->{ID};
my $subcats = $DB->table('Category')->children($cat_id);
push @$subcats, $cat_id;
my $link_db = $DB->table('Links','CatLinks');
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', $subcats);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}
Thanks!



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
Quote Reply
Re: [IndigoClothing] Help in showing links in higher catogories In reply to
This should work:

sub {
my $output;
my $tags = shift;

return '' unless ($tags->{ShowSubCategoryLinks});
my $cat_id = $tags->{ID};
my $subcats = $DB->table('Category')->children($cat_id);
push @$subcats, $cat_id;
my $link_db = $DB->table('Links','CatLinks');
$link_db->select_options ("ORDER BY $CFG->{build_sort_order_cat}");
my $condition = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', $subcats);
my $sth = $link_db->select($condition);
while (my $link = $sth->fetchrow_hashref) {
$output .= Links::SiteHTML::display ('link', $link);
}
return $output;
}

Last edited by:

afinlr: Jul 19, 2005, 4:18 AM
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Thanks Laura but I get this error:

Quote:


A fatal error has occured:
Can't call method "fetchrow_hashref" on an undefined value at (eval 27) line 13.


Your help is really appreciated.



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
Quote Reply
Re: [IndigoClothing] Help in showing links in higher catogories In reply to
Sorry - can't see what the problem is without more info. Can you just turn on debugging and give me the error message?
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
A fatal error has occured:
Can't call method "fetchrow_hashref" on an undefined value at (eval 27) line 13.


Please enable debugging in setup for more details.Stack Trace ======================================
[REMOVED]



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery

Last edited by:

IndigoClothing: Jul 19, 2005, 5:39 AM
Quote Reply
Re: [IndigoClothing] Help in showing links in higher catogories In reply to
Thanks (you might want to edit that post and delete the info now).
Hmm - the $CFG variable doesn't seem to be there - and I don't understand why.
I'll have to think about this.
Quote Reply
Re: [IndigoClothing] Help in showing links in higher catogories In reply to
Which version of Links are you using - I wonder whether these variables are named differently in version 3?
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Hi,

Using 2.2.0 still. Any other questions just give me a shout.

Alex



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery

Last edited by:

IndigoClothing: Jul 19, 2005, 5:40 AM
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Blush should be build_sort_order_category - sorry - thought I'd checked this.

If you use this:

$link_db->select_options ("ORDER BY $CFG->{build_sort_order_category}") if ($CFG->{build_sort_order_category});

you shouldn't get the error message even if it doesn't work.
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Laura,

No worries - Thank you so much - that should really help visitors to my site Smile

Hope you are enjoying the summer - rather grey in London today.

Alex



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
> >