Populating posting.php message field from form submission on phpBB3 forum
I'm trying to add a form button that will take a variable string and insert it into $_POST['message']
, such that when someone presses my 'post this on forum' button it takes them to the new topic page with my variable string already in the m开发者_高级运维essage textarea
.
I've been messing with submit_post
and have a form that submits a new post correctly when it's completed, however I don't want it to submit straight away; all I want is for it to load posting.php
with my string already in the message field. Does anyone have any ideas?
You might have to modify the source of phpBB3 in order to do this. Unless posting.php
is programmed to accept data from $_POST
and insert it into the message textarea
, you'll have to program it to do so.
As an alternative, you could try doing this with JavaScript: You could pass the text to posting.php
in a cookie or a session variable which then displays in a hidden div
or textarea
or some other means (I'd need more specific information about your environment to provide specifics) and then insert that text into the textarea
using JavaScript after the page loads. This should be more upgrade safe, but obviously requires users to have JavaScript enabled.
I found an alteration you can make to posting.php to let it accept get parameters http://www.phpbb.com/community/viewtopic.php?f=46&t=2119831
Here it is for the sake of completion:
Find the following in posting.php:
if ($submit || $preview || $refresh)
Add the following on a line before it:
if( !$submit&& !$preview&& !$refresh&& !$save&& !$load&& !$delete&& !$cancel&& ( $mode== 'post'|| $mode== 'reply'|| $mode== 'quote' ) ) {
$post_data['post_subject']= utf8_normalize_nfc( request_var( 'subject', '', TRUE ) );
$message_parser->message= utf8_normalize_nfc( request_var( 'message', '', TRUE ) );
Voila! Test it with http://yourdomain/forum/posting.php?mode=post&f=2&subject=hello&message=world
精彩评论