Working with Categories
- 1 - Installation.......
- 2 - Let’s Create a Channel.......
- 3 - Let’s Create a Template.......
- 4 - Using File Fields Part 1: Set Up.......
- 5 - Using File Fields Part 2: Templating.......
- 6 - DRY Template Layouts and Partials.......
- 7 - Moving the System Directory Above Webroot.......
- 8 - Variable Modifiers.......
- 9 - Working with Categories.......
- 10 - Working with Relationships.......
- 11 - Partials, Embeds, Variables.......
- 12 - Let’s Create a Channel Layout.......
- 13 - Routing.......
- 14 - Contact Form.......
- 15 - Adding A 404 Page.......
In this video, we will add a category group and categories to our blog, as well as display them in our blog template.
What We Do
- Create a category group
- Create categories
- Assign a category group to channels
- Show category loop in our most recent posts
- Use the
backspace
parameter
Code Snippets
Adding Category Loop To Display Name
{!-- Categories --}
<p class="text-sm leading-5 font-medium text-indigo-600">
{if has_categories}
{categories backspace="2"}<a class="hover:underline" href="/blog/entry/{url_title}">{category_name}</a>, {/categories}
{/if}
</p>
{!-- End categories --}
Links
- ExpressionEngine ChannelEntries Loop: https://docs.expressionengine.com/latest/channels/entries.html
- ExpressionEngine Categories Loop: https://docs.expressionengine.com/latest/channels/categories.html
- ExpressionEngine Backspace Parameter: https://docs.expressionengine.com/latest/channels/categories.html#backspace
- See all of the site build in action in the Learn EE git repository.