I’m not sure what I’m doing wrong but the {active} conditional variables does not do anything on my side.
From the docs:
<a href="http://{path=%27news/index%27}" class="active">{category_name}</a>
You may use this conditional to test whether the category shown is the active category or not, based on the dynamic URI segment.
If I understand this correctly, this is supposed to indicate if the category is active correct? I want to style the active category on which an entry is posted. Example:
<h4 class="heading-primary"> Categories</h4>
{exp:channel:categories channel="blog" show_empty="no" class="nav nav-list mb-xlg"}
<a href="http://{path=%27blog%27}" class="active">{category_name}</a>
{/exp:channel:categories}
It only displays the categories on my template, but it makes no different if I use the active conditional or not.
You are correct, I was missing the conditional if tags. This works but only if I trigger the category keyword in the URI.
Example, the {if active} conditional works if you are on:
example/template/category/acme
I create a categories menu, and it will indeed here highlight the ACME category as active. (category is here my trigger work configured in EE)
But this does work on a channel entry.
I have the same category menu on each article. If you are browsing the categories URL, it works. But once you click on some article, the URL is obviously different since it’s now using the channel entry name to create the URL and EE does not know to that category that article belongs.
The code to generate the categories’ menu nested is the same, both on the categories template page and the template page that displays articles.
I guess I would ask if that’s really the behavior you want.
For example, with categories, you may not want the category menu item active when on a single article because technically the category itself is no longer active as a single entry could be related to multiple categories. If you were to do that dynamically, you could end up with multiple “active” categories.
If you’re doing this to mimic a structure like what we have on the docs, then you really should look at something like Structure or Construct which really bring page like hierarchy to EE. Remember that EE is not a page-building CMS. It’s about the content and as such is agnostic to how you display it. We’re actually about to release a new tutorial series on building in EE that does a great job of explaining this.
Come to think of it TJ’s Category Construct might give you the functionality you need while sticking with categories. I’ve never set up a site using it, but you can read through the docs or ping him on Slack and see if it’ll do what you need.
Thank you for the reply. That is correct, I did end up with having multiple categories displayed. I will take a look at some add-ons and see which one is a better fit for my page builds.
I never actually used EE as a CMS on its own, I rather build my design agnostic to it and only used basic functionality over the years, but I decided to drop another PHP software I was using and slowly migrate the same functionality to EE to have everything unified. I think EE will be up to the job with some native functions, some queries and some PHP, everything together should prove rather powerful to replicate most interactivity.
The irony is that I did more complex things on EE, but I’m now struggling with basic things because I never used the channels or categories properly before. I was also not sure about EE future’s under Ellis Lab, but now I’m confident it has a future again with the latest updates and under the new owner.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.