We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Show categories grouped by category group ID for different channels

Development and Programming

nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

Hi,

I’m a total newbie to the EE. 
I’m trying to do such thing with this engine, however I need your advice.

I wan’t to create the site about different diseases. I need to creat mechanism that will allow reader to find his own type.

Page 1:

F.ex.

A Ankle pain Abdominal pain H Headache Heartache

The list of different diseases A-Z.

Page 2:

If the reader pick one of them he will see three different stauses of diseases. For example. 
Ankle pain one RED Ankle pain two RED

Ankle pain three YELLOW

Ankle pain four BLUE

And then after clicking on this he will be able to read the article. 
I did create three channels for this three colours RED, YELLOW, BLUE and ascribe cateogories of the diseases to each channel.

I used for page 2 this code:


<div class="blue">
{exp:channel:entries channel="BLUE" status="open"}<ul>
<li>
<a href="http://{title_permalink=site/page3}">_
{title}</a></li></ul>{/exp:channel:entries}
</div>
<div class="yellow">
{exp:channel:entries channel="YELLOW" status="open"}<ul>
<li>
<a href="http://{title_permalink=site/page3}">_
{title}</a></li></ul>{/exp:channel:entries}
</div>

<div class="red">{exp:channel:entries channel="RED" status="open"}<ul>
<li>
<a href="http://{title_permalink=site/page3}">_
{title}
</a></li></ul>
{/exp:channel:entries}</div>


QUESTION: How to generate on page two list of the categories for all channels grouped by category group ID. Is it possible with the EE or I need to buy some plugins (which one?).

I have already purchased the Category ID plugin, however it’s not what I need I guess…

I really appreciate your help.

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

Hi nicomsw

How does a Blue entry differ from a Red or Yellow entry? The reason I ask is that if the structure is the same i.e. they use the same custom fields, then it may be better to just have a single Channel called “Diseases” and use multiple category groups instead.

Category Group 1 “ColourStatus” contains the categories: Red, Blue, Yellow etc. Category Group 2 “Ankle Pain, Wrist Pain etc…”


to attempt an answer of your question:


QUESTION: How to generate on page two list of the categories for all channels grouped by category group ID. Is it possible with the EE or I need to buy some plugins (which one?).
{exp:channel:categories channel="RED|BLUE|YELLOW" show_empty="no" category_group="1|2|3"}
  {category_name}
{/exp:channel:categories}

The tag above renders a hierarchical list of categories parented by category groups. See here: http://ellislab.com/expressionengine/user-guide/modules/channel/categories.html

You can render plain text too if you use the parameter: style=”linear”

If you wanted to break the formatting and show the Category Groups in their own divs for example, you could use…

<div class="categoriesBox">
{exp:channel:categories channel="RED|BLUE|YELLOW" show_empty="no" category_group="1"}
  {category_name}
{/exp:channel:categories}
</div>

<div class="categoriesBox">
{exp:channel:categories channel="RED|BLUE|YELLOW" show_empty="no" category_group="2"}
  {category_name}
{/exp:channel:categories}
</div>

<div class="categoriesBox">
{exp:channel:categories channel="RED|BLUE|YELLOW" show_empty="no" category_group="3"}
  {category_name}
{/exp:channel:categories}
</div>
       
nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

Hi Matt,

thank you for your help. I really appreciate it.

Well, the Blue Red and Yellow entry has to be presented in different divs, that’s why I’ve used the different channels for them. Maybe it is problem with my thinking…

I’ve tried the

{exp:channel:categories channel="RED|BLUE|YELLOW" show_empty="no" category_group="2"}

however it does not working… It generates empty space for some reason. If use only one channel

{exp:channel:categories channel="RED" show_empty="no" category_group="2"}

it works fine. What is the problem?

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

Hi

Sorry, its possible that you can only specify a single Channel using the standard Categories tag.

Are you happy to use this method?

{exp:channel:categories channel="RED" show_empty="no" category_group="2"}
it works fine.
       
nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

Not, at all, because when I use show_empty=”no”, then I’m not able to see categories from f.ex blue and yellow. The only way is to put it to “yes”. Then it will show all the categories.

Maybe there is some plugin that will allow to use channel=”RED|BLUE|YELLOW” ?

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

OK, let’s turn this on it’s head and use an ENTRIES tag instead. We know that Entries tags can look at more than one Channel…

{exp:channel:entries channel="RED|BLUE|YELLOW"}

  {categories}

    {category_image} <a href="http://{path=channel/index}">{category_name}</a>

  {/categories}

{/exp:channel:entries}

Here’s more info: http://ellislab.com/expressionengine/user-guide/modules/channel/variable_pairs.html#var_categories

       
nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

That could work, but if I use entries then it generates all diseases three times f.ex

headache, headache, headache…

that’s because it has three channels.

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

So we’re running into the problem of displaying duplicates… because we’re storing duplicates…

I would go back to the single Channel and assign Category Groups as needed, especially if the Custom Fields for each Channel entry are the same between RED, BLUE and YELLOW.

       
nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

Ok, if I’ll use:

Category Group 1 “ColourStatus” contains the categories: Red, Blue, Yellow etc. Category Group 2 “Ankle Pain, Wrist Pain etc…”

as you have mentiond. Will I be able to differ it on the last page. For example If I will Publish post in:

Category Group1 Blue Group 2 Ankle Pain

And then another post: Category Group1 Red Group 2 Ankle Pain

will I be able to get:

Ankle Pain post 1 Ankle Pain post 2

using different divs?

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

Using your objective…

Assuming you have a single Wrist Pain entry and TWO Ankle pain entries.

Category Group 1 contains these Categories: Red “id:1), Blue (id:2), Yellow (id:3” Category Group 2 contains these Categories: Ankle Pain (id:4), Wrist Pain (id:5)

<div id="redDiseases"><!-- render diseases in the Red group -->
  {exp:channel:entries channel="disease" category="1"}
    {title} post {count}
  {/exp:channel:entries}
</div>

would display: Ankle Pain post 1 Ankle Pain post 2

and…

<div id="blueDiseases"><!-- render diseases in the blue and wrist pain groups -->
  {exp:channel:entries channel="disease" category="2|5"}
    {title} post {count}
  {/exp:channel:entries}
</div>

would display: Wrist Pain post 1

       
nicomsw's avatar
nicomsw
35 posts
14 years ago
nicomsw's avatar nicomsw

Unfortunatelly I think it won’t do…

In this case it should look like that:

Category Group 1 contains these Categories: Red (id:1), Blue (id:2), Yellow (id:3) Category Group 2 contains these Categories: Ankle Pain (id:4), Wrist Pain (id:5)

but it should generate on the second page entries from the same Category Group (in your exaple it’s two). but it should has different colours depends on what the post.

F. ex.

Page one:

A.

Ankle pain

W.

Wrist pain.

Then if you click on the Ankle pain it should go to page 2.

Page two:

(post number 1) Ankle Pain and fewer. (post number 2) Anke Pain and headache without the fewer.

Moreover: I will be adding the categories not now, but though the time. So it can’t be specified by id (becasue there is no catetories in group 2 for now). And I don’t wan’t to edit template for every new category…

Oh, a what a mess…

       
Matt:P's avatar
Matt:P
277 posts
14 years ago
Matt:P's avatar Matt:P

ok, take it easy. We’ll get there!

Do you have a mockup of what the site will look like? Maybe we’re not understanding the objective well enough.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.