Trying to replace posts/messages when they're rendered

SneakyDave

Well-known member
There are probably a lot of examples like this in the RM, but I can't seem to find any to provide me an example of this.

At a basic level, all I want to do is change the content of posts/messages displayed on a page. Not the db values, just as they are rendered.

Using the thread view as a starting point, I thought I could simply extend the model that retrieves posts to massage this data, but I think there is some caching going on, because the $content never seems to be updated with the text I have set for the posts in the thread view controller.

Would using a template modification on the "message" template work better?
 
Hey Andy, thanks a lot. That provided a lot of information.

It seems though that there's a post cache that needs to be refreshed too, I found (from your addon) that I can change the _params['post'][$key]['message'], but the _params['post'][$key]['message_parsed'] is actually what may be used in htmlRender().

Not a big deal, probably better to leave the cache in place for performance, but I can't tell how long it's kept. That's probably why my idea in the first post wasn't working.

EDIT:
Actually Andy, I don't believe your addon works quite the way you have intended it to. It's the same problem I'm having.

In your add-on, if you censor a word, and then have just a certain usergroup affected by that censor (say, the unregistered user group), other usergroups will still see the censor affect, at least in my testing it does. Even if I have the add-on permisison set to "No/Never".
 
Last edited:
Whoops, never mind @AndyB, your add-on works correctly, I had confused xenforo's native censor function with your addon. Back to some testing.

Regarding the caching, it seems that if I disable the "cache bbcode output" that fixes the issue.
 
Last edited:
Top Bottom