# [Free Plugin] Hashtagger v1.1

4,926 views
asked Feb 11, 2014 in Plugins

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
• 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

2. Extract files to the ./qa-plugin/ directory
3. Enjoy!
Q2A version: 1.6.3
commented May 27 by
https://github.com/ProThoughts/q2a-hashtagger

Let us know if you see any issues, we can improve.
commented May 30
@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!

- AK

Thank you very much. I activated hashtagger with Q2A 1.6.3 and is working fine.

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

Disabled - requires Question2Answer 1.6.3 or later

commented Feb 18, 2014 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"
commented Feb 18, 2014
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.
Very nice plugin. Everything works with Latin characters, but does not work with Cyrillic characters. Please what can be done to Cyrillic character work?
commented Feb 18, 2014 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.
commented Feb 18, 2014
Thank you Victor. Works fine. Changed codes qa-hashtagger.php all "\w" with "\pL"

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

ps. Рад то смог помочь. Насчёт пробелов — очень трудно сделать, так чтобы всё работало нормальным образом. Дело в том, что плагин не может «знать» если после пробела идёт слово или имя пользователя. Более того, в имени пользователя могу быть более двух пробелов и почти нереально угадать кому было адресовано сообщение (например, если у вас есть такие пользователи «Иван», «Иван Иванов» и «Иван Иванов Димитрович»). Единственное что можно сделать, так это запретить пользователям использовать пробелы в имени пользователя.
Can I remove links from a tag rel="nofollow" . Since these links on the tag and opt user within the site.
commented Feb 18, 2014 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.
commented Feb 18, 2014
Hm. Thnaks. It's clear.

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.

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
commented Jun 13, 2014
@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
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!

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

commented Dec 17, 2015 by
You could use @john+smith.( I didn't test this but I think it works)
commented Dec 17, 2015
commented May 7, 2016
Any solution for this?
+1 vote

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 ?

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];
}
}

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

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?

asked May 31, 2016 in Plugins hashtagger plugin problem