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

Same content for specified category and all subcategories

Quote Reply
Same content for specified category and all subcategories
Hi,

I would like to display the same content for specified category and ALL its subcategories (unlimited deep).

But, as you already guessed, I don't have a clue how to do it Wink.

Actually I know, with 'Category Template', but this is too complicated, confusing and time consuming.



What I would like to do:



<%if category_id eq '2' OR ITS SUBCATEGORY ???%>

Show something

<%elsif category_id eq '10' OR ITS SUBCATEGORY ???%>

Show something different

<%elsif category_id eq '32' OR ITS SUBCATEGORY ???%>

Show something different too

etc...

<%endif%>



Any help is welcome!

Thanks in advance!
Quote Reply
Re: [Payooo] Same content for specified category and all subcategories In reply to
I am trying to do eactly above.

Any global to pull the all subcateories for a categoty?

thanks.
Quote Reply
Re: [hegu] Same content for specified category and all subcategories In reply to
Use istart. For example:

Code:
<%if Full_Name istart = "Test 1"%>
bla bla
<%elseif Full_Name istart = "Test 2"%>
bla bla
<%elseif Full_Name istart = "Test 3"%>
bla bla
<%elseif Full_Name istart = "Test 4"%>
bla bla
<%endif%>

"istart" basically makes it check if the value STARTS with the value you enter. So for the first one - it would do:

Test 1/
Test 1/Something
Test 1/Something/Whatever
...etc

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] Same content for specified category and all subcategories In reply to
Thanks Andy.

I will try that.
Quote Reply
Re: [hegu] Same content for specified category and all subcategories In reply to
Working on Category pages. But not on Detailed pages. Same code I pasted there. Why?

thanks.
Quote Reply
Re: [hegu] Same content for specified category and all subcategories In reply to
It wouldn't work on detailed pages. For it to work on detailed page, you would need *another* global *(i.e still have the current global, but also add this global)

get_cat_name_for_detailed
Code:
sub {
my $catid = $DB->table('CatLinks')->select( ['CategoryID'], { LinkID => $_[0] } )->fetchrow;
my $name = $DB->table('Category')->select( ['Full_Name'], { ID => $catid } )->fetchrow;
return { Full_Name => $name } ;
}

..then call to:

Code:
<%get_cat_name_for_detailed($ID)%>

...then you will be able to use the FulL_Name tag in detailed pages.

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: [hegu] Same content for specified category and all subcategories In reply to
I added a global: get_cat_name_for_detailed
with your code above.

In detailed page I keep it like this:

<%get_cat_name_for_detailed($ID)%>
<%if Full_Name istart = "vategory one"%>
content one
<%elseif Full_Name istart = "Category two"%>
content two
<%elseif Full_Name istart = "Category two"%>
content three
<%endif%>

Not working plus footer dissappearing in detailed pages.
Quote Reply
Re: [hegu] Same content for specified category and all subcategories In reply to
When you say "not working", what do you mean?

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] Same content for specified category and all subcategories In reply to
The content is not displaying as it supposed to based on the 'isstart'. PLUS no html after this code is not displaying in html source.(footer is dissappearing)
Quote Reply
Re: [hegu] Same content for specified category and all subcategories In reply to
So what does the whole template look like? Just paste ALL the code here - otherwise, not a lot I can suggest.

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] Same content for specified category and all subcategories In reply to
I just PMed the code.

thanks!