Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How to show parent category links in child category pages

Quote Reply
How to show parent category links in child category pages
How to make parent category links "sticky" in a child category page?

For example:
I would like to show all links belonging to San Diego category to San Diego/Museums page as a separate, "sticky" list.

Thank you in advance!
Quote Reply
Re: [AMIXIMA] How to show parent category links in child category pages In reply to
Hi,

I'm not sure I understand what your asking for? You want to make a link "related", so it shows in additional categories?

Cheers

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!
Quote Reply
Re: [Andy] How to show parent category links in child category pages In reply to
Hi Andy,

I would like to achieve the following:

For example in San Diego Category page i have links like:

San Diego Link 1
San Diego Link 2
San Diego Link N

I would like to list the links belonging to San Diego category also under San Diego Museums category as a separate link loop like this


San Diego Museum Link 1
San Diego Museum Link 2

More Links from San Diego
San Diego Link 1
San Diego Link 2
San Diego Link N

Ideally, if its possible, I would like to integrate links from any category ID I specify instead of only FatherID for more flexibility.

Do you think its possible?
Quote Reply
Re: [AMIXIMA] How to show parent category links in child category pages In reply to
Ok, I think I understand what you want. I guess the easiest way is to add a new field via Database > Category > Properties > Add Field:

RelatedCatID / INT

Then enter the category ID. Then add a new global:

get_related_from_catid
Code:
sub {
my $link_db = $DB->table('Links','CatLinks');
my $cat_id = $_[0];
my $limit = 50;

my @output;
$link_db->select_options ('ORDER BY Title', "LIMIT $limit");

my $sth = $link_db->select ( { CategoryID => $cat_id }) || die $GT::SQL::error;


while (my $link = $sth->fetchrow_hashref) {
$link = Links::SiteHTML::tags('link', $link);
push @output, $link;
}

return { extra_links_loop => \@output }
}

Call with:

Code:
<%if RelatedCatID%>
<%get_related_from_catid($RelatedCatID)%>
<%if extra_links_loop.length%>
<%include link.html%>
<%endif%>
<%endif%>

Hopefully thats what your after ;) (totally untested!)

Cheers

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!

Last edited by:

Andy: Jul 23, 2013, 12:12 PM
Quote Reply
Re: [Andy] How to show parent category links in child category pages In reply to
Andy,

Thank you so much!

I'll test it now and let you know about the outcome.
Quote Reply
Re: [Andy] How to show parent category links in child category pages In reply to
Andy,

Could you please check again the code, i was unable make it work?
Whatever id i was providing for <%get_related_from_catid($RelatedCatID)%>

(be it $RelatedCatID, $FatherID or just 20013) the extra_links_loop.length is always 0.

Armen
Quote Reply
Re: [AMIXIMA] How to show parent category links in child category pages In reply to
Sorry, try the modified one.

Cheers

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!
Quote Reply
Re: [Andy] How to show parent category links in child category pages In reply to
Hi Andy,

after small change in your include code everything works fine now. Thank you again for your answers and as a small token of my appreciation I ordered for you one of the items from your amazon gift registry. Enjoy!

Armen
Quote Reply
Re: [AMIXIMA] How to show parent category links in child category pages In reply to
Hi,

Glad it worked :)

Quote:
and as a small token of my appreciation I ordered for you one of the items from your amazon gift registry.

Ah thank you Cool

Cheers

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!