Show tag cloud by author

I have a website that has many users, each with its own mini-site. Part of this “mini-site” is the blog. I would like to show a tag cloud for each author. The main cloud function of Tag and Tagger will do this, but for ALL authors. Adding author_id does not work.

I tried using a loop of feed entries to get all entries from the author, and then show 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 gave me a list of tags that only the author used (in the tag, it did not work in Tagger). However, if the tag was used more than once, it listed it more than once.

The Native EE and Tag function will not let me do what I want to do. I will probably need to use php (plug-in) for this. We select all the tags that the author used, put them in an array, delete duplicates, and then output them to my template. I posted a post on Solspace, but they said that I would need to use PHP.

Before I did this, I wanted to see if there was a simpler method or some other addition that could do this. I also welcome any advice on approaches in such a plug-in, if that is the way to go.

+4
source share
2 answers

Using Tagger and the query module, you can get what you need (maybe Solspace Tags, too, I just did not use this one, so I can’t say for sure).

Query like this

 SELECT tag_name FROM exp_tagger WHERE author_id = 7 

Gives a set of tags for this author.

You can use it with a request module like this, using the current author_id entry as the dynamic part of the request.

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

Unfortunately, I think your only option here is custom PHP to remove duplicates.

+1
source

Source: https://habr.com/ru/post/1442501/


All Articles