Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Help in showing links in higher catogories

(Page 1 of 2)
> >
Quote Reply
Help in showing links in higher catogories
Hi All


Ok I was hoping I could get some help here as I am new to link SQL and am just starting to learn all the features, my problem is as follows:


I plan to run the directory as such:


TOP:- Companies

SUB:- asia

SUB:- Usa

SUB:- Europe

---------SUBSUB:- UK

---------SUBSUB:- Germany

---------SUBSUB:- France

Etc, etc


My deal here is I would like it if say the visitor clicks on Europe, they will see all links within the sub catergories: uk, germany, france etc, but then they can narrow the links down then by clicking on say france which then will just show links in france.


I am hoping someone can tell me how to do this.


I hope I havenĺt confused anyone by what I want to do if so I will try to explain better.


Thanks before hand.

Kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.

Last edited by:

mekro: Feb 26, 2002, 2:03 AM
Quote Reply
Re: [mekro] Help in showing links in higher catogories In reply to
Hi,

You could do this by copying the link. Goto Browse in your admin and click on the link and copy it into both categories.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Help in showing links in higher catogories In reply to
Isn't there a way to make parent category shows all the links of the subcategories automaticly.?
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
I've been thinking about this.

It would be similar to how eBay uses their directory, where subdirectories are to aid in refining a search, not the actual 'storage' area the way it is in DMOZ or Yahoo.

To be effective, this would probably need a change to the kernal code, and a configuration option in the admin area -- ie: group_subcategory_links Yes/No (1/0).

Most people don't want it to work this way, they want to use the upper categories for "special" or paid listings.

Alex would really need to address this, or provide some insight before I could take it any further. I can see how it would maybe work, but I have not really delved too deeply into the search engine and the traversal of the parent/child hierarchy.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Help in showing links in higher catogories In reply to
I don't know perl. But I think the whole idea is, when the links are called for a category, there should be an additional call for all the links in the subcategories.
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Yes, but it's a bit more complicated, because you need to first find the categories that are sub categories, then pick out links that are members of all those categories. I'm sure the functions exist in Links, since Alex has to be calling something to get the category totals, but as I said, this is really the one area of Links (besides the admin code) that I've not gone into at all. It's also the area of Links that the most changes from version to version seem to be in.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Help in showing links in higher catogories In reply to
I see. Then a small hint from Alex will solve the problem :)
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Hi,

This would require a bit of work to implement. Your basic steps are:

1. Add a new field to the Category table saying 'ShowSubcategoryLinks' that is set to either Yes or No.

2. Add a global called subcategory_links that is on the category.html template. It would look something like:

Code:
my $tags = shift;
my $cat_id = $tags->{CategoryID};
return '' unless ($tags->{ShowCategoryLinks});
my @subcats = $DB->table('Category')->select ( FatherID => $cat_id )->fetchall_hashref;
my $output = '';
foreach my $subcat (@subcats) {
$output .= "$subcat->{Name}<br>";
my @links = $DB->table('Links', 'CatLinks')->select ( CategoryID => $subcat->{ID})->fetchall_hashref;
foreach my $link (@links) {
$output .= "$link->{Title}";
}
}
return $output


Obviously it needs better formatting to make it look how you want, but that's the general idea.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Help in showing links in higher catogories In reply to
Hi Alex,

Thanks for your help... :)



I've having some problems implementing this mod.

First,

should unless ($tags->{ShowCategoryLinks});

Be unless ($tags->{ShowSubcategoryLinks}); ?

I've done this change, and now I'm getting this error:

A fatal error has occured:
No such pseudo-hash field "Name" at (eval 17) line 8.


It seems that there is a problem with:

$output .= "$subcat->{Name}<br>";


Any suggestion?



Thanks,

Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
More details about the error:

fatal error has occured:
No such pseudo-hash field "Name" at (eval 18) line 8.


Please enable debugging in setup for more details.Stack Trace======================================Links (12354): Links::environment called at /home/look4ara/public_html/cgi-bin/admin/Links.pm line 418 with no arguments.Links (12354): Links::fatal called at (eval 18) line 8 with arguments (No such pseudo-hash field "Name" at (eval 18) line 8. ).Links (12354): Links::__ANON__ called at /home/look4ara/public_html/cgi-bin/admin/GT/Template.pm line 763 with arguments (HASH(0x85b9378)).Links (12354): GT::Template::_get_var called at /home/look4ara/public_html/cgi-bin/admin/templates/yahoo/compiled/category.html.compiled line 172 with arguments (GT::Template=HASH(0x85ba240), subcategory_links, 0, 1).Links (12354): GT::Template::__ANON__ called at /home/look4ara/public_html/cgi-bin/admin/GT/Template.pm line 539 with arguments (GT::Template=HASH(0x85ba240)).Links (12354): GT::Template::_parse called at /home/look4ara/public_html/cgi-bin/admin/GT/Template.pm line 93 with arguments (GT::Template=HASH(0x85ba240), category.html, HASH(0x82dbc74)).Links (12354): GT::Template::parse called at /home/look4ara/public_html/cgi-bin/admin/Links.pm line 291 with arguments (GT::Template, category.html, ARRAY(0x859c8dc), HASH(0x82dbc74)).Links (12354): Links::user_page called at /home/look4ara/public_html/cgi-bin/admin/Links/SiteHTML.pm line 125 with arguments (category.html, HASH(0x83d5b6c), HASH(0x82dbc74)).Links (12354): Links::SiteHTML::site_html_category called at /home/look4ara/public_html/cgi-bin/admin/GT/Plugins.pm line 102 with arguments (HASH(0x83d5b6c), [undef]).Links (12354): GT::Plugins::dispatch called at /home/look4ara/public_html/cgi-bin/admin/Links/SiteHTML.pm line 28 with arguments (GT::Plugins, /home/look4ara/public_html/cgi-bin/admin/Plugins, site_html_category, *Links::SiteHTML::site_html_category, HASH(0x83d5b6c), [undef]).Links (12354): Links::SiteHTML::display called at Links::Build::build_category line 164 with arguments (category, HASH(0x83d5b6c)).Links (12354): Links::Build::build_category called at /home/look4ara/public_html/cgi-bin/admin/GT/Plugins.pm line 102 with arguments (HASH(0x8215a18)).Links (12354): GT::Plugins::dispatch called at /home/look4ara/public_html/cgi-bin/admin/Links/Build.pm line 30 with arguments (GT::Plugins, /home/look4ara/public_html/cgi-bin/admin/Plugins, build_category, *Links::Build::build_category, HASH(0x8215a18)).Links (12354): Links::Build::build called at /home/look4ara/public_html/cgi-bin/admin/Links/User/Page.pm line 127 with arguments (category, HASH(0x8215a18)).Links (12354): Links::User::Page::generate_category_page called at /home/look4ara/public_html/cgi-bin/admin/Links/User/Page.pm line 59 with no arguments.Links (12354): Links::User::Page::handle called at /home/look4ara/public_html/cgi-bin/admin/GT/Plugins.pm line 102 with no arguments.Links (12354): GT::Plugins::dispatch called at page.cgi line 25 with arguments (GT::Plugins, /home/look4ara/public_html/cgi-bin/admin/Plugins, handle_page, CODE(0x824cabc)).
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
anybody?
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
up
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Is it possible that you dont have Name column in Category table?
Or you renamed it?

It seems the Name column is missing, that causes the error.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Hi, Please try this code, I don't think the error is related to any missing or wrongly named columns, it is just a few minor code issues...

Try this (untested):

Code:
my $tags = shift;
my $cat_id = $tags->{CategoryID};

return '' unless ($tags->{ShowSubCategoryLinks});

my $subcats = $DB->table('Category')->select ('Name', { FatherID => $cat_id })->fetchall_hashref;
my $output = '';

foreach my $subcat (@$subcats) {
$output .= "$subcat->{Name}<br>";
my $links = $DB->table('Links', 'CatLinks')->select ('Title', { CategoryID => $subcat->{ID} })->fetchall_hashref;
foreach my $link (@$links) {
$output .= "$link->{Title}";
}
}
return $output;

Last edited by:

Paul: Apr 9, 2003, 4:57 AM
Quote Reply
Re: [Paul] Help in showing links in higher catogories In reply to
Hmm. Yes, Paul, it's likely that you are right, and it's a reference usage problem...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [Paul] Help in showing links in higher catogories In reply to
Thanks Paul,



I tried it, no errors anymore. But the links still doesn't show in the upper categories.
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
anybody? Smile
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
up
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
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'}</a>~;
}
return $output;
}
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
Quote:
\@$subcats

You are dereferencing $subcats and then re-referencing :)

Just use:

$subcats
Quote Reply
Re: [Paul] Help in showing links in higher catogories In reply to
Thank you Blush
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
PERFECT. Finally it works. Thank you very much afinlr and paul.
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
small needed change... how can I output the link template instead of just the link?

This link I think need to be modified:

$output .= qq~<li><a href="$CFG->{db_cgi_url}/jump.cgi?ID=$link->{ID}">$link->{'Title'}</a>~;
Quote Reply
Re: [Essam] Help in showing links in higher catogories In reply to
Just change it to

$output .= Links::SiteHTML::display ('link', $link);
Quote Reply
Re: [afinlr] Help in showing links in higher catogories In reply to
thank you afinlr , we are lucky to have you here.
> >