Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to alter the render after a post?

drukargindrukargin New
edited August 2012 in Vanilla 2.0 - 2.8

I am writing a plugin that replaces text matching a certain pattern in a discussion or comment body before render. So the basic idea is, if a body contains a pattern, that pattern will be stored in the database but will appear as something else entirely.

For new page loads, this is working great using DiscussionController_BeforeDiscussionRender. However, I am having trouble finding what to hook to do these substitutions immediately after posting a comment. Changing any of the 'body' fields I can find in Senders from PostController_BeforeCommentRender, _BeforeCommentsRender, and _AfterCommentSave has no effect on the ajax'd output after posting a new comment.

Any ideas?

Thanks!

Comments

  • AoleeAolee Hobbyist & Coder ✭✭
    edited August 2012

    please correct me if i didn't get it correctly. you wanted to transform something it the discussion or comment content submitted before you save it in the db?

    if yes, why not just , save the content as it is then just trasform when the content will be displayed? this way your saving the original content posted by the user?

  • That is actually what I am doing. :) I found the right hook; I need to alter $Sender->CommentData->Result->FirstRow()->Body on DiscussionController_BeforeCommentsRender and PostController_BeforeCommentsRender. This handles new page loads and ajax loads.

    Thanks!

  • peregrineperegrine MVP
    edited August 2012

    @Aolee said:

    why not just , save the content as it is then just trasform when the content will be displayed? this way your saving the original content posted by the user?

    @drukargin
    it is better to transform on display rather than modifying content in database in my opinion.

    AfterCommentFormat_Handler

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I am transforming on display; I'm manipulating the result of the query, not the information in the database. The database stores a token, which the plugin transforms into human-readable data. I'll take a look at AfterCommentFormat, though I think I want to be before that.

    Thanks again!

Sign In or Register to comment.