By sethcohn on
Is there an easy way to generate a _clean_ list of taxonomy terms used in the most recently created nodes?
Playing with views, I could create a list of terms used, but not a list with duplicates removed, multiple terms split apart (ie no commas), etc.
I'm thinking along the lines of 'Recent Topics Discussed', so I don't want the cruft of doubles/etc, just a way for someone to see XYZ was discussed, and a single link (via taxonomy) to items using that term.
Seems simple enough, but for some reason I don't see an 'out of the box' way to generate it...
Comments
You can look at the
You can look at the Suggested Terms module for examples on getting recent terms:
hmm, have to check that out...
At first, I didn't think that would work, thinking it's recently created and not recently used, but I think the join might make it work...
I'll follow up shortly.
ah ha, I think I've got it...
Well, wasn't quite as easy as the above sql, but close enough.
The complexity: We want the greatest of the nids, otherwise if it returns an older node nid, we'll lose the fresher nids (and show more stale terms first). We also want no duplicates in terms, and the typical "group by" picks some nid, not the newest, unless we add the max select.
This gave me the results I want...
Now, for bonus points, is there a better SQL query to give the same results?
Subscribing, looking for
Subscribing, looking for optimal sql also.
greetings,
Martijn
Order by node update/changed
Here is a query that will select recent terms based on node update/change, and not based on 'nid' as the above query. I haven't tried this on a large data set, but I imagine it is rather slow as it has two joins.