For the most part, this module works great! Only a couple of things I can't seem to figure out:
1) I'd like to autotag with terms in my selected vocabulary that have a depth > 1 - for instance:
-Fruit
--Apple
--Orange
--Banana
-Bread
--White
--Wheat
--Grain
I'd like to autotag with "Apple", "Orange", "Wheat", etc. and NOT "Fruit" and "Bread". I was looking into the possibility of hook_rules_autotag_terms_alter(), but wasn't sure if this was the best approach.
2) I have unwanted tagging due to the way my vocabulary is currently set up. For instance, my vocabulary has something similar to:
-Computer
--Computer 1
--Computer 1a
--Computer 1b
--Computer 2
--Computer 2a
-Radio
--Radio 1
--Radio 2
--Radio 14
--Radio 26
In nodes that have a body that contains "Radio 26", auto tags are generated as "Radio" (hence my question above in #1), "Radio 2", and "Radio 26". The reason why this is happening seems to just be because of the use of strpos() in rules_autotag_extract()...
What do you think?
Comments
Comment #1
dasjohi hawkeye217,
1) you could try to achieve that by removing unwanted terms using
hook_rules_autotag_terms_alter2) sounds like you would like to match for "Radio 2 " and "Radio 26 " instead?
Comment #2
hawkeye217 commentedSeems that way, those are exactly what I was thinking - however I'm hoping the maintainer of this module would be able to point me in a more specific direction as far as code modification...
Comment #3
dasjothe provided steps should help you get going, good luck and feel free to ask more specifically
Comment #4
hawkeye217 commentedWell as I thought in my initial assessment in my OP, strpos() was the problem here... preg_match() seems to be the better choice for matching the exact term in my situation.
Original code in rules_autotag.module:
if (strpos($text, $result['original_term_name']) !== FALSE) {
Should be changed to something like:
if (preg_match("/\b$word\b/i", $text)) {
where $word = $result['original_term_name']...
For my first problem in the OP above, I had to hack rules_autotag_get_term_names() to add an inner join to the db_query statement in order to find taxonomy terms in the selected vocabulary that had a parent (taxonomy_term_hierarchy table, parent != 0). Definitely a hack, but it's achieving the results I was looking for.
Hope this helps anyone else out there with the same issue!
Comment #5
dasjoi think we should mark this as "works as designed" as the requested workaround is specific to this certain use case.
feel free to reopen if you think we need to provide better hooks for this