![]() |
Messing with $post[message] in functions_newpost.php-The quest continues! Form vars?
I want to add a snippet of code to each $post[message]. It's for a modification I'm working on. How can I add, say, a conditional clause to it? I tried editing the postbit template and it didn't work...
|
As you mentioned, editing the postbit(_legacy) template should be sufficient. What exactly did you do?
|
What I'm trying to do is, again, set up this automatic BBCode thing that I've been looking for.
I tried setting it up like this: Code:
<if condition="$post[field11] AND $post[field12]">$post[field11]</if> |
You need to convert the BB Code into HTML (called "parsing"). This needs to be done inside a plugin. (There are articles describing how to parse BB code.)
|
https://vborg.vbsupport.ru/showthrea...ghlight=bbcode
I'm not quite sure what I'm doing here. I started out on this code: Code:
<if condition="$post[field11] AND $post[field12]"> --------------- Added [DATE]1235735146[/DATE] at [TIME]1235735146[/TIME] --------------- Is there any way to just modify what goes in to $post[message]? |
You cannot do php in a template. You will have to write a plugin to do that.
|
Can't I just fiddle with the $post[message] instead? Wouldn't that be simpler?
|
If you are going to 'fiddle' with $post[message] before it is spit out in the template, you must do so using a plugin.
|
Oooh... I see. And which plugin hook? I'm guessing Postdata_Start, but I really don't know where all these hooks go to.
|
If you are in debug mode, there is a list of all the plugins called for the page on the bottom. I think I usually use postbit_display_start when I want to change something that is going into the postbit. But, you can certainly try different locations.
|
When I try to put something into postbit_display_start, like, say
Code:
echo "this is a test statement"; --------------- Added [DATE]1235820573[/DATE] at [TIME]1235820573[/TIME] --------------- Okay... I wrote this plugin: Postdata_start Code:
if ($post[field11] && $post[field12]) Code:
<if condition="$post[field11] AND $post[field12]">$parsed_text But when I tried it out, no HTML was outputted. And this is probably a serious security risk, seeing as people can type in PHP code for the fields and have it execute. How can I change that? |
one way to find out where to execute your code is to look in tje php files themselves. for instance, showthread.php for stuff dealing with posts.
If you look through the code you will see the hook locations. Basically you can find out what hook is being called where. Once you know where it is being called in the code, you can go back to your plugin manager and write your code for the hook that will execute where you want it to. for instance, on line 1078 of showthread.php i see [code] ($hook = vBulletinHook::fetch_hook('showthread_postbit_crea te')) ? eval($hook) : false; [/hide] so if i were to make a plugin inside that hook it know it will be executed when that hook is called in the php file. I dont really know if its the best way to find out which hook is t he right one for your needs, but it works for me quite often :D |
Come on... Can't anyone help me out here? :(
|
Which file processes the form from replies? Which actual PHP file in vBulletin?
|
Go to the page and look in the page source. You will find some line like this (this is from somewhere else, it's not it):
HTML Code:
<form action="newthread.php?do=postthread&f=11" method="post" name="vbform" onsubmit="return vB_Editor['vB_Editor_001'].prepare_submit(this.subject.value, 5)"> |
One final question, and then I think I'll FINALLY have this stupid issue! (Breakthrough was reached by just scanning all the files that seemed relevant for a comment telling me about "this is where we process posts).
What I did was this: In file: functions_newpost.php Find: PHP Code:
PHP Code:
As to my questions... 1. Will a variable that works well in the template (in this case, the aforementioned field variables) work as they are there in the files? Like say I put this string in functions_newpost.php (where I put the last string I mentioned): PHP Code:
|
Bump?
|
If you are talking about the build_new_post() function, no, it will not work.
|
GAAAAAAAAAAAAAAAH
So it's also impossible to get the info to there? How about setting a plugin that way? The guys over at MTGSalvation and MTGNews figured it out somehow! Sorry if I sound a little hysterical; I am. |
postbit_display_complete ;)
|
Neither adds the info to the post nor parses it. :(
|
Actually, just add it to postbit_display_start instead. The parser is run just after that.
|
I tried that, then it just does nothing. It doesn't even add it to the html code.
|
And the code you are using is?
|
PHP Code:
|
PHP Code:
|
That worked! OMG Thanks! :D
One question though-what's $this? |
Object Oriented PHP :)
|
I'm just gonna stop asking there, because I'm 99% sure that I'll never get it. Ever. :D
|
Quote:
PHP Code:
|
All times are GMT. The time now is 02:45 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|