I moved from EE2 to EE3.

I used to use BW Category Count by Wouter Vervloet to make several conditionals over content, verifying if a category group has zero, one, x, or more presences in a entry.

That helped me a lot to make custom description texts for our entries.

So, for example, I was able to do this:

    {exp:channel:entries channel='schools'}
    {title} has 
    {if "{category_count show_group='7'}" < 1}no teachers. {/if}

    {if "{category_count show_group='7'}" == 1}one teacher named 
    {categories show_group='7'}{category_name}{/categories}{/if}

    {if "{category_count show_group='7'}" == 2}two teachers, named 
    {categories show_group='7' backspace="2"}{category_name} and {/categories}{/if}

    {if "{category_count show_group='7'}" > 2}several teachers, named 
    {categories show_group='7' backspace="2"}{category_name} and {/categories}{/if}


Explanation: I have a channel named "schools". Have several category groups. One of them (group_id "7") is "Teacher's Names". So, in my school description, I need to show different texts depending on how many teachers a school has.

That's what "BW Category Count" does, it counts categories inside a group so you can use that result... for example, in a conditional.

Is there an alternative to achieve this using EE3, as the plugin will not have a EE3 version?

I know EE3 added "Added {if no_results} to {categories} tag pair in {exp:channel:entries} loop", but that's not enough for our needs.

Edit: It's "BW Category Count" and not "Category Count". Sorry! Thanks in advance

  • 1
    Can you expand your code block a little? A quick look at the reference shows that your code example must live in a {exp:catcount} loop. The parameters passed and the outer block it lives in might shed some light on possible solutions. Just asking because I don't know the add-on at all, but some extra context might hint at a solution.
    – jrothafer
    Feb 14 '16 at 4:09
  • Jrothafer, I edit the original question, added some code to clarify. The code works fine in EE2. Thanks for your time. Feb 14 '16 at 8:35
  • If all you need is a count of categories, have you considered writing a quick plugin?
    – jrothafer
    Feb 14 '16 at 12:59
  • would be nice, however i don't know how to do that. Feb 14 '16 at 22:04
  • 1
    Are you a PHP developer? If so, I can probably give you enough of an intro to EE add-on development to get you going. If not, you might be out of luck until either BW Category Count gets updated for EE 3 or someone releases an add-on with similar functionality. Your last ditch option would be the first-party Query add-on. It would be messy for your use case but you could basically craft MySQL queries to cover this template. Also, you'd have to know MySQL decently for that option. Someone else chime in!
    – jrothafer
    Feb 15 '16 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.