EllisLab text mark
Advanced Search
     
Check If a Weblog is in a Category Group
Posted: 23 June 2012 12:16 PM   [ Ignore ]
Avatar
Joined: 2011-04-14
7 posts

I was wondering if there is a way in a template to check to see if the current weblog is in a specific category group (not category, category group)?  I have look around but not found anything on this which makes me wonder if this is impossible??

Thanks!

 
Posted: 25 June 2012 04:57 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

Hi DWhiting,

Interesting question!

Since categories can be shared among weblogs, and are technically assigned to entries, I don’t think there is a way to get that information on the weblog level.

Is there anything else I can assist you with?

Cheers,

 Signature 

How may I help you?

 
Posted: 25 June 2012 09:32 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2011-04-14
7 posts

Thanks for your replay.  I sorta figured that is wasn’t going to be simple confused

I did some playing around and came up with a way to accomplish what I was looking for.  I will post it below for others who want to do the same thing.

It really is not a conditional as much as it will only display the code if the post is in a specific category group.

Commets and suggestions are welcome grin

<!--Use below code to determin if post is part of a specfic category group-->
{exp:weblog:categories weblog="weblog_name" category_group="category_group_id"}
{exp
:weblog:entries weblog="weblog_name"  category="{category_id}"}
      
<!--Code to run if post is in Category Group above-->
      <!--If 
the post is not in the Category Group then nothing will be displayed-->
{/exp:weblog:entries} 
{
/exp:weblog:categories} 
 
Posted: 28 June 2012 01:44 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-11-25
7174 posts

Hey DWhiting,

That’s awesome. Nice work here!

I will move this over to the Community Help Forum so more community members can benefit.

Cheers,

 Signature 

Recent version: EE 2.5.4 | Forum Module 3.1.10 | MSM 2.1.4 | 2.x Bug Tracker | Version Upgrade