Should mentions and hashtags be working in comments? Both are working fine in the main statuses text area, but they don't appear to be working when replying to (commenting on) a status update. Just wondering if this was default behavior before I start troubleshooting. Thanks!

Comments

icecreamyou’s picture

Status: Active » Fixed

Yeah unfortunately the way the submodule was implemented it tracks the relationship between @mentions/#hashtags and statuses in the database, so it's not designed to work on other content like status comments. However I think it's actually possible to make it work on comments without a patch by doing something like this (untested) in a custom module:

function mymodule_preprocess_fbss_comments_item(&$vars) {
    $vars['comment']->comment = statuses_tags_add_links($vars['comment']->comment);
}

I'm certainly open to a patch if anyone wants to add support for something like this.

jweirather’s picture

Thanks for getting back. I'll try your sample code on our site and let you know how it goes. If it does work, I may also try my hand at a patch.

Thanks again for all your efforts on this module.

jweirather’s picture

As an aside (or +1), I've found that on my other social sites it seems that the feed "subscribers" use mentions in comments at least as often as the authors do in the original posts. As in: a "subscriber" tagging their friends who might not otherwise see or notice a given post. Just wanted to (ahem) mention that.

It's not as true for hashtags, but definitely for mentions.

Just my $0.02.

jweirather’s picture

Initial feedback: I'm on the beta2 version, and quickly modified the code to:

function mymodule_preprocess_fbss_comments_item(&$vars) {
    $vars['comment']->comment = statuses_tags_process_message($vars['comment']->comment);
}

Note: statuses_tags_process_message. This did attempt to add the link to the comment, but it was encoded (by t function?) "...@<a href="..."

I'm going to attempt to upgrade to the dev version and revert to your original code to see if the issue persists and confirm that the mention is recorded and appears in the default views. In the meantime I wanted to post this back to see if you foresee any additional issues and/or point me in the right direction. I'm happy to try to sort it out, but any direction would be appreciated.

Thanks!

jweirather’s picture

*note that the encoding I'm trying to paste is being rendered as html. suffice it to say that the processed message has URL encoded strings instead of a properly formatted link.

jweirather’s picture

Updated to the dev version and the same issue persists.

The link code is trying to work, but this is the output as shown in the comment itself:

@<a href="/users/username" title="View user profile." class="username" xml:lang="" about="/users/username" typeof="sioc:UserAccount" property="foaf:name" datatype="">username</a>

(In the resulting page's source code, that output is URL encoded.)

I'm happy to play this our further and try a patch, but would appreciate any guidance to get me started in the right direction.

Thanks

jweirather’s picture

Status: Fixed » Needs work

Setting back to "needs work", as I do plan to work on this, and remain open to feedback/help

icecreamyou’s picture

statuses_tags_process_message() was renamed to statuses_tags_add_links() in dev to avoid conflicting with the Message module.

The problem you're experiencing is that the preprocess hook adds the links before the input filter is run over the comment, and the input filter converts the HTML links to plaintext. If you change the input filter you're using to allow HTML links in your comments, it might work for you.

Avoiding this issue without modifying the module would probably require implementing hook_theme_registry_alter() and providing an entirely new theme callback for status comments instead of the default theme_fbss_comments_item(). (You could do something tricky in it like calling theme_fbss_comments_item() explicitly and then parsing the output, but that would be pretty gross.) Alternatively that function could be patched to add links if the statuses_tags module is enabled. Ideally there would be a setting for that, and there would be additional utilities for finding status comments with specific #hashtags/@mentions in them (or statuses with status comments that have specific #hashtags/@mentions in them...) but that's probably overkill for your use case.

jweirather’s picture

Thanks for getting back with the detailed reply, it definitely shed some light on the situation. I recently had to enable HTML in statuses, so I'm curious to see if this fixes it. I'll be circling back to this in the next few weeks and will report back with results/patch.

While we're on the subject, I don't believe the UI offers the ability to choose Statuses text formats by role, but is there a way to do this with a theme function or hook? For example, I don't want normal users to be able to post HTML into statuses, but system-generated statuses should allow it.

Thanks again-

JPW

icecreamyou’s picture

I don't believe the UI offers the ability to choose Statuses text formats by role, but is there a way to do this with a theme function or hook?

You can probably do this in a MODULE_process_HOOK() implementation or in a theme in order to change how individual statuses are rendered. You'd also need to change your Views though since statuses rendered through Views are constructed through Views fields. I'm sure there's a way to make that work - not sure exactly the right approach offhand.

ugintl’s picture

did you get it working?