Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+28 votes
11.0k views
in Plugins by

Hashtagger is a free plugin for Q2A which automatically converts hashtags (#some_word) and mentions (@some_name) into HTML links when users publish/edit questions, answers or comments.

Hashtags
When a user submits a message, the plugin will replace hashtag (#some_word) with HTML link to the tag page. For example: the #free-plugin will be replaced with <a href="/tag/%23free-plugin">#free-plugin</a>. Please note, that all missed tags will be automatically inserted into question tags, with no matter where it was added — question, answer or comment. This is done to prevent broken links.

Mentions
When a user submits a message, the plugin will replace mention (@some_name) with a HTML link to user profile and will send an email to the mentioned user. For example: the @admin will be replaced with <a href="/user/admin">@admin</a> and he will receive an email which contains the name of user which mentioned it and a full URL where he can read the message. Please note that plugin will skip mention, if mentioned user cannot be found in database.

URLs
Depending on options of the URL structure, on your site the URL examples specified above may have a different format, as the plugin automatically detects which URL format need be used

Options
In Administration Centre you can enable or disable any of the following options:

  • Handle questions
  • Handle comments
  • Handle answers
  • Enable hashtags (convert #some_word to tag link)
  • Keep "#" symbol for tags names
  • Enable mentions (convert @some_name to user profile link)
  • Notify the user when it is mentioned


Installation

  1. Download hashtagger.zip
  2. Extract files to the ./qa-plugin/ directory
  3. Enjoy!
Q2A version: 1.6.3
by
@Kappagantula Aditya, I do have this plugin, will upload on github and provide link to you.
by
I appreciate that very much! Thank you :)
by
@Kappagantula Aditya, you can download plugin from below location.
https://github.com/ProThoughts/q2a-hashtagger

Let us know if you see any issues, we can improve.
by
@q2a.info

I was playing around this plugin and i am confused about what is the username field that will get converted to a hyperlink and how the notifications work?

Are there any special instructions for external-user integration?

Is there any db table that we need to create ?
Any set of instructions on making this plugin work would be great!

Thanks in advance!
- AK

12 Answers

+2 votes
by
Thank you very much. I activated hashtagger with Q2A 1.6.3 and is working fine.
0 votes
by

Thank u, it does not work with version 1.6.2 :( 

Disabled - requires Question2Answer 1.6.3 or later

by
I cannot test it now and I don't know if will work for 1.6.2, but you can edit the plugin file (./qa-plugin.php) and instead of "Plugin Minimum Question2Answer Version: 1.6.3" write "Plugin Minimum Question2Answer Version: 1.6.2"
by
i have tested, it and it"s work.
for next version :)
1- add autosuggest box under the textarea, then can user select tags or username that are from 2 word or more.
0 votes
by
Very nice plugin. Everything works with Latin characters, but does not work with Cyrillic characters. Please what can be done to Cyrillic character work?
by
Very strange, because I have tested it and its works perfectly with Russian. Maybe your server is not configured properly? Anyway, try to replace in ./qa-plugin.php all "\w" with "\pL". Please let me know if it worked.
by
Thank you Victor. Works fine. Changed codes qa-hashtagger.php all "\w" with "\pL"


p.s. Спасибо большое. Все работает отлично без проблем. Я вот хотел спросить как можно решить проблему с пробелом? Так как у меня на сайте люди заригиструется например Иван Иванов.
by
Great. I’ll add this fix in the next release.

ps. Рад то смог помочь. Насчёт пробелов — очень трудно сделать, так чтобы всё работало нормальным образом. Дело в том, что плагин не может «знать» если после пробела идёт слово или имя пользователя. Более того, в имени пользователя могу быть более двух пробелов и почти нереально угадать кому было адресовано сообщение (например, если у вас есть такие пользователи «Иван», «Иван Иванов» и «Иван Иванов Димитрович»). Единственное что можно сделать, так это запретить пользователям использовать пробелы в имени пользователя.
0 votes
by
Can I remove links from a tag rel="nofollow" . Since these links on the tag and opt user within the site.
by
The "nofollow" is added when the page is displayed (not when saved). This is why you should use another solution which removes the "nofollow" attributes.
by
Hm. Thnaks. It's clear.
0 votes
by

How can I fix the problem with the question. At issue hashtag works but seems ID, issue the following link. And in response to the comments and works without problems.

+2 votes
by
Hi, thanks for your plug-in. I love it and works fine! I noticed just a little issue using "wysiwyg-editor" plug-in. If you edit the text, applying a color, the hashtagger plug-in automatically reads colors like #cccccc as hashtag. So the colors don't be applied on text and the plug-in creates new hashtags for each color applied on text. For now I disabled the color palette from the editor with this code in my css, waiting for a fix:

#cke_14 {display:none !important;}

Sorry for my english, best regards
by
@Victor: This is a good point, the plugin should ignore all # within <tags>, this way this bug can be prevented. Probably this needs a DOM parser. That's why I would, by the way, implement this plugin in jquery ;) http://stackoverflow.com/a/21422891/1066234
0 votes
by
This is a great plugin! Thanks so much!

Only request/question I have is if there's a way to override the tag requirement if a hashtag is used. I have our site set up so that questions require at least 1 tag in order to be posted. It would be really nice, and I'm sure a giant pain to code, if the # tagged items in the body text could count towards that limit so that users don't have to enter them twice. I know I could turn off the requirement, but I know half of our users will use the # indicator while the other half will use the tag field.

Thanks again for the great work and for making it FREE!
0 votes
by

The plugin works fine except that it doesn't work for  usernames like john smith. Is there a way to fix this problem?

by
You could use @john+smith.( I didn't test this but I think it works)
by
@fara: Your solution didn't work:-(
by
Any solution for this?
+2 votes
by

This only captures the user names which are wither single word or in the format of demo-admin or demo_admin. But it won't accept users with two names which is the case in most of the scenarios. If we ask the users to type "+" instead of a space, how could the user name matching can be changed to @(?P<name>[\w\-\+]+) . But how can I derive the actual user name out of it ?

Please help.

Update :

I used the above regex to validate a user name (where the space is considered as a +), then I changed the build_user_link function as below.

private static function build_user_link($match)
{
    $match['name'] = str_replace('+', ' ', $match['name']); // I added this line
    $userid = qa_handle_to_userid($match['name']);
    if ($userid) {
        self::$userids[] = $userid;
        $url = qa_path_html("user/{$match['name']}");
        return "<a href='{$url}'>@{$match['name']}</a>";
    }
    else {
        // If user does not exists in DB the string is returned as is
        return $match[0];
    }
}
by
did not work as well in 1.7.5
should i miss something? This is the most clever and best possible way to solve the issue. But it did not :((
by
finally it worked. Praneeth Nilanga Pei you are genius :)
+2 votes
by

in the question form if I mention a user, it changes it to:

qasite.com/687/user/username

as you know it must be without the question number, so that a correct user link. 

BTW it works fine in answers, why in questions?

+3 votes
by
Thanks, but download link is broken. Can you upload hasttagger.zip again :)
by
@Aykut Büyükkılıç, you can download from here
https://github.com/ProThoughts/q2a-hashtagger
+3 votes
by
I've fixed some issues with the plugin and published them here: https://github.com/pupi1985/q2a-hashtagger
by
Good to see you still help out Q2A :)
by
Thanks. I'm still around :)
by
mention notification inside that on-site notification would have been nice.  Any way to add it there.
by
That's something the on-site notification plugin developer should take care of :)
...