ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Check If a Weblog is in a Category Group

June 23, 2012 12:16pm

Subscribe [2]
  • #1 / Jun 23, 2012 12:16pm

    DWhiting

    5 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!

  • #2 / Jun 25, 2012 4:57pm

    Dan Decker

    7338 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,

  • #3 / Jun 25, 2012 9:32pm

    DWhiting

    5 posts

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

    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 😊

    <!--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}
  • #4 / Jun 28, 2012 1:44pm

    Shane Eckert

    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,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases