14 - Tagging in ExpressionEngine

Implement tags in ExpressionEngine using Tagger from DevDemon.

 
Download the EE Code for 14 - Tagging in ExpressionEngine

The Folder Template that we are working with shows tags on each blog post.  This brings up the question - just what are Tags in the EE world and how do they differ from other ways of organizing content?

Tags vs. Categories
Tags and Categories are very similar. They are both “buckets” that you can create then assign a channel entry into. On the front end a user clicks a bucket name from a list and gets the channel entries (blog posts in our case) that are assigned into that bucket.

So how are they different?

Categories have more meta-data and more structure. ExpressionEngine allows me to create a category description, add a category image, create heirarchy in the list of categories, and I can also create custom category fields if the native ones don’t do the job well enough.

Categories are also more permanent. Often (but not always) the category structure is decided during the site build along with the rest of the site’s content structure. As the EE developer you can set permissions that dictate whether a content administrator can affect the category structure or not.

Tags are simpler, often created on-the-fly by the content administrator. Tags are (usually) 1-3 words, and you don’t get a way to describe them more with photos or descriptions. Due to their more dynamic nature tags often require maintenance, with tags getting consolidated due to misspellings, redundancies, or tags that are too close in meaning.

ExpressionEngine has category functionality built-in, but has never offered tagging as a native feature.  This is where the 3rd Party Add-on market comes into play.

Available Tagging Add-ons
I found the following Tagging addons available for ExpressionEngine:

I had originally intended to do a comparison article pitting all of these add-ons against each other, but eventually realized the time it would take to do so was keeping me from getting this series going again so I just made the decision to use Tagger by DevDemon. It’s free, it has some traction in the market, it has support, and it hasn’t been abandoned to GitHub by it’s creator. Good enough..:)

Installation
Installation is pretty straightforward and standard per the instructions on the DevDemon site. From there the docs jump just to template tags however, so I’ll fill in the gaps of how to get entries tagged.

Tag Group
In the Tagger Control Panel I created a new Tag Group called “blog”.

New Fieldtype
The Tagger Module also adds a Tagger field type and entries are tagged using a Tagger Channel Field that exists in the Channel Field Group assigned to the Channel. In our case, this means each blog-related field group needs a new Tagger field. I created the following six new Tagger fields in their like-named Channel Field Groups using the default settings mentioned after the list of field names:

  • blog_audio_tags
  • blog_image_tags
  • blog_link_tags
  • blog_post_tags
  • blog_quote_tags
  • blog_video_tags

Field defaults:
Show: Most Used Tags Yes
Use a single field to add and display tags: No
Automatically assign all tags to a tag group: Blog

Tagging Process
With the new fields created if you go into an existing entry you should see Tagger’s options at the bottom now. As you enter tags they should appear in the list of Most Used Tags. Edit your content to assign tags so when we update template code we’ll know if it works.

Front-end Code
For now all I want to do is display the correct tags on the blog entries. In the next installment we’ll create the template that each tag links to and displays all the entries assigned to that tag.

You’ll need to edit each blog-entry-related Snippet and change this static code:

<span class="tags"><a href="#">red</a>, <a href="#">cyan</a>, <a href="#">white</a>, <a href="#">blue</a></span

To this code that uses the Tagger tag loop:

<span class="tags">
    
{exp:tagger:tags entry_id="{entry_id}" backspace="6"}
            
<a href="/blog/tag/{tagger:urlsafe_tagname}">{tagger:tag_name}</a>,
    
{/exp:tagger:tags}
</span

Much like our “loop within a loop” approach to displaying Categories in ExpressionEngine entries Tagger also requires a loop that exists inside a standard EE Channel Entries loop. We pass in the entry_id variable so Tagger knows which tags to pull, and we use the backspace parameter to remove the comma from the last tag displayed. I’ve linked the tags to a non-existent /tag/ template that we’ll create in the next installment.

Results
With Tagger installed, existing content marked up with tags, and the new Tagger code saved in your Blog entry Snippets you should now have dynamic, linked tags appearing in both the Blog index view and all Blog single-entry pages.

I’ll include the updated Snippets with the Companion Files for this chapter.

 

 

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of Gary Braid

by Gary Braid

Date: Tuesday, January 21st, 2014
Comment: #1

Hi Mike,

Thanks for the latest in a very good series of articles, been hoping you’d do the tagger one as it is something I needed to learn for a client site.

Thanks for your hard work & generosity for doing it for free, although if it does become a book will get a copy for sure.

cheers

Gary

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, January 21st, 2014
Comment: #2

Thanks for hanging in there Gary. It’s funny how quickly time can slip by - but I do intend on finishing this series. The jury is still out on if it will be polished up into a book.

Picture of Athar

by Athar

Date: Wednesday, May 28th, 2014
Comment: #3

Hi Mike,
I have installed all things as per your guideline but i am not getting Tag Group any where in admin panel , i have installed module , feild type but not getting any tag related option in CP home/Add-ons/ Extentions

is any option I am missing to get it done.

Thanks,
Athar Haider

Mike Boyink

by Mike Boyink (Author)

Date: Wednesday, May 28th, 2014
Comment: #4

Hey Athar - If you aren’t seeing it in the CP then it’s not installed correctly.

The DevDemon folks provide tech support for their stuff though - so installation problems should be directed to them.

Picture of Ukie Girl

by Ukie Girl

Date: Saturday, September 6th, 2014
Comment: #5

I’m confused with the Tagger module. It’s installed and shows up in my CP where it’s supposed to, but when I go to make the channel field, I don’t see any of the default options you listed above.

I’m making the channel field in the regular spot. Am I supposed to do it else where?

Picture of ukiegirl

by ukiegirl

Date: Saturday, September 6th, 2014
Comment: #6

D’oh!

I missed the tagger type in the drop down box… no wonder it wasn’t working. All seem well now.

Picture of cialis

by cialis

Date: Sunday, July 19th, 2015
Comment: #7

 

Add Your Comment

Commenting is not available in this channel entry.

Unless otherwise stated all content is © Michael Boyink of Train-ee.com & Boyink Interactive. Please don't steal - I've got kids to feed...

dy>