Search code examples
tagsexpressionenginecategorieschannel

Tags and category - ExpressionEngine


I develop for the first time on EE and I don't really understand the categories.

I created categories with names and everything is linked.

When I'm selecting a category and update my post, on the blogpost page, every categories are displayed.

enter image description here enter image description here

Here is the code:

{exp:channel:categories channel="blogs"}
   <li><a href="{path='blog/categories'}">{category_name}</a></li>
{/exp:channel:categories}

Second question :

Is there a way to have tags and categories ? with a dropdown menu or something like that ?

Thanks in advance


Solution

  • When I'm selecting a category and update my post, on the blogpost page, every categories are displayed.

    The Channel Categories Tag shows all categories by default, regardless of whether any posts are categorized that way. To override this you just need to set the show_empty parameter to no

    Try

    {exp:channel:categories channel="blogs" show_empty="no"}
       <li><a href="{path='blog/categories'}">{category_name}</a></li>
    {/exp:channel:categories}
    

    See the documentation


    But...Since from your comment it sounds like you want to just show categories assigned to a given entry, there is a different tag to use.

    There is a variable pair available inside the Channel Entries tag for categories

    Inside your exp:channel:entries tag pair you will want to add something like

    {categories}
        <a href="{path='your/template_path'}">{category_name}</a>
    {/categories}
    

    You might find some useful info in this answer, too.


    Is there a way to have tags and categories ? with a dropdown menu or something like that ?

    To have tags on your site you can use one of the tagging add-ons available for EE. I recommend Tagger or Solspace Tag.