Hi, I'm looking for a way to implement tags similar to twitter hashtags to the comments in a project I'm working on. This way, when an user writes something like:
This is an #example of auto-tagging
The word #example would be converted to a real taxonomy term and then associated with the comment (or node).
For the main description of Rules Autotag I've understood the module works with closed taxonomies and it "simply" compares the content of the node (and other fields) with certain rules for adding the matching terms. Am I right or could Rules Autotag handle generic rules creating the needed missing terms?
Regards and thanks in advance for your response.
PS. There will be a second problem, showing content tags with a different look or as links to the corresponding taxonomy page. This can be easily achieved using Custom Filters module.
Comments
Comment #1
dasjobasically i don't know of closed vs. dynamic vocabularies in drupal. maybe you are referring to the autocomplete / tagging widget type that you can use to that extend.
the described use case isn't covered by rules autotag, as it compares words of a given full-text against a given set of terms that usually live in a vocabulary. what i understand is, that you would like to have it extract previously unknown #hashtags, add them to the vocabulary and tag it.
currently i don't how to do that, an approach might be extending hook_rules_autotag_terms_alter() by passing $text as well, what would allow for injecting additional tags from a prior hashtag analysis.
regarding the hashtag extraction i googled
http://stackoverflow.com/questions/3060601/retrieve-all-hashtags-from-a-...
Comment #2
NoRandom commentedYes, I meant that: closed = taxonomy with predefined terms, dynamic = taxonomy where common users are allowed to add new terms.
So, by your response, I understand that Rules Autotag compares the words in the node content with the terms of certain vocabulary wich is not compatible with what I would like to do. My php skills are very low but I'll take a look to the code and I'll try to implement new tags creation.
About the hashtags extraction, it's really easy to do for simple tagging system like #whatever using regex (like in the link you put).
Thanks.
Comment #3
dasjothinking it over again, this wouldn't really need the logic that rules autotag has right now.
so it could basically be an alternate component (example: rules_hashtag) that implements the features discussed above
Comment #4
NoRandom commentedThanks again, dasjo.
After finding a little bit confusing rules module, I've started to program a small module to achieve what I want. My main problems have solution now and I "only" need to put them together.
Comment #5
dasjogreat to hear NoRandom,
would you like to share your code so others can learn from it?
Comment #6
NoRandom commentedYes, when I finish I will share it. Unfortunately, my php skills and drupal knowledge are really low so I'm not able to create a goog-looking and very user friendly module. For example, I don't know how tho choose the taxonomy that'll be used using a proper form inside a configuration page for the module. So, it'll be a very rough aproximation to the final purpose.
Comment #7
dasjoare you still using rules as part of your solution?
Comment #8
NoRandom commentedNot by now, I'm building it from scratch. But when I'll have it working I would like to take a closer look at rules to see if it could be done with it.
Comment #9
dasjoexactly, so why i was asking is because with rules you would get "choosing the taxonomy" right out of the box.
there is lots of documentation available on how to develop using rules
http://drupal.org/node/878928
see for example the Extract tags action that rules_autotag defines, its quite straight forward
http://drupalcode.org/project/rules_autotag.git/blob/refs/heads/7.x-1.x:...
Comment #10
NoRandom commentedMy first plan was to develop a quick module by myself and then try to replicate it using rules but yesterday I found a big problem. Basically:
And here is the problem; it shouldn't be difficult but after struggling like 5-6 hours with the drupal documentation and looking inside the code of modules like yours and others, I don't know how to assign a taxonomy term to my comment.
At this point, I decided to try replicating the process using rules. Well, I've just started but it seems that I can extract hashtags and create its corresponding terms easily using php code. Then, although I haven't tried yet, I could use Rules Autotag to assign them to the comments. What concerns me is the performance of the site since Rules Autotag works with predefined vocabulary and I want to use with an open one where users could easily create thousands of terms. So, it seems that finally I need to know how to assign terms to comments using PHP.
Regards, thanks in advance and sorry for this long post.
Comment #11
dasjoi don't think comments support taxonomy terms in drupal 7, but maybe i'm wrong
Comment #12
dasjoi don't think comments support taxonomy terms in drupal 7, but maybe i'm wrong
Comment #13
NoRandom commentedYes they do ;)
And, after more hours, problem solved. Actually it seems to be really easy, you simply need to build an array with the term ids and voilà.
The module finally works as I wanted (but lacks any kind of configuration), let's see if I'm able to replicate it using rules.
Regards.
Comment #14
dasjothanks for sharing your accomplishments
Comment #16
balagan commentedI was searching for a similar thing, but in my use case I want to associate fields and their specific content with specific terms to add. I think I can go simply with the synonyms modul. Would that work?
I also had the idea for this use case of using the synonyms module with computed fields. That might also work, I don't know if synonyms module supports computed fields, but then opening a feature request there might help.I was just thinking, synonyms might be used for a lot of other things, even here to define hashtagged words to categorize comments.