PDA

View Full Version : Writing a new hack to change the way a post is displayed, suggestions on a starting p


jwocky
11-19-2007, 12:56 AM
Hey everyone..

What i'd like to do is to write a hack that will format certain posts into a different style (similar to the way vb.org reformats the first post for the threads related to a mod).

My idea was to use my own internal code to determine that a post should be formatted differently

So for example, a post that starts out with the words: "[REFORMAT]" would trigger my plugin to activate and take the words that follow "[REFORMAT]" and do something, for example change the font size or color. I will probably make it reformat the entire post, using placement of the text in different areas, but for now lets keep the examples simple just to figure out how to get it done. So for example, I want to take the words after "[REFORMAT]" and make them red by inserting <font color=red>after "[REFORMAT]"

Now I don't know where to begin in terms of which hook to use to plugin my code to read the current post that is being processed and if it meets the criteria of containing "[REFORMAT]"

I can code the php part of it fairly easily, but which hook would be the one to use, and what variable is the actual post contained inside?

Thanks everyone!!

Analogpoint
11-19-2007, 07:33 PM
I'd use the postbit_display_complete hook and check/change the contents of the $post['message'] variable.

jwocky
11-20-2007, 05:37 PM
I'd use the postbit_display_complete hook and check/change the contents of the $post['message'] variable.

Thanks so much for the tip, its much appreciated, can't wait to start on it tonight.

The content in $post['message'] is just the entire post in a raw format that the vb php files will process to make it html friendly right? For example if I edit $post['message'] to rearrange the content into columns via adding in html tables and such code, would it work?

Another followup question, if I want to edit the post to show any attachment images in a different style, is there a variable such as $post['message'] that handles the attachments?

Analogpoint
11-20-2007, 09:06 PM
Thanks so much for the tip, its much appreciated, can't wait to start on it tonight.

The content in $post['message'] is just the entire post in a raw format that the vb php files will process to make it html friendly right? For example if I edit $post['message'] to rearrange the content into columns via adding in html tables and such code, would it work?

Another followup question, if I want to edit the post to show any attachment images in a different style, is there a variable such as $post['message'] that handles the attachments?

I believe by the time you get to this hook, $post['message'] contains the HTML output for the post contents.

If you want to display attachements differently, there are other attachment hooks to do that. Or just edit the attachment templates.