Search code examples
expressionengine

Showing a tag cloud by author


I have a site that has many users, each with their own mini-site. Part of this 'mini-site' is a blog. I'd like to show a tag cloud for each author. The basic cloud feature of Tag and Tagger will do this, but for ALL authors. Adding an author_id doesn't work.

I tried to use a channel entries loop to get all the entries by author, then show the tags associated with these entries.

{exp:channel:entries author_id="1" channel="blog"}
{exp:tag:tags entry_id="{entry_id}"}
<li>{title}<a href="#">{tag_name}</a><span>{total_entries}</span></li>
{/exp:tag:tags} 
{/exp:channel:entries}

This did get me a list of tags that only that Author has used (in Tag, it didn't work in Tagger). However if a tag was used more than once it would list it more than once.

Native EE and Tag functionality won't let me do what I want to do. I'll probably need to use php (a plug in) to do this. Fetch all the tags an author has used, put them in an array, remove duplicates, then output this into my template. I did post at Solspace, but they said I'd need to use PHP.

Before I did that I wanted to see if there is a simpler method or some other add-on that can do this. I would also welcome any tips on approaches in such a plug in if that is the way to go.


Solution

  • Using Tagger and the Query Module you should be able to get what you need (probably Solspace Tags, too, I just haven't used that one so can't say for sure).

    A query like this

    SELECT tag_name  
    FROM exp_tagger
    WHERE author_id = 7
    

    Gives a set of tags for that author.

    You can use it with the Query Module like this, using the current entry's author_id as a dynamic part of the query.

    {exp:query sql= "SELECT tag_name FROM exp_tagger WHERE author_id = {author_id}"}
        {tag_name}
    {/exp:query}