using the posting_modify_submit_post_before event in my listener, accessing it somewhere else with
Code: Select all
$event['data'] = array_merge($event['data'], array(
'custom_mode' => (isset($_POST['c'])) ? true : false,
));
Code: Select all
$event['data'] = array_merge($event['data'], array(
'custom_mode' => (isset($_POST['c'])) ? true : false,
));
$request
class in your listener? Yeah I have, unless I forgot to add it it to my services.yml file. I'll update you in a bit.Ger wrote: ↑Fri Jun 08, 2018 10:17 am Have you injected the$request
class in your listener?
Look here for example: https://github.com/GerB/modernquote/blo ... hp#L39-L41
and
https://github.com/GerB/modernquote/blo ... ces.yml#L5
$this->request->is_set_post('c')
Toxyy wrote: ↑Fri Jun 08, 2018 9:49 am Trying to get a variable I added in a url, posting.php?c=1&.......
using the posting_modify_submit_post_before event in my listener, accessing it somewhere else with
Now, I've tried (isset($_POST['c'])) ? true : false, request_var('c', 0), $this->request->variable('c', 0), and nothing is working. I must be missing something simple here.Code: Select all
$event['data'] = array_merge($event['data'], array( 'custom_mode' => (isset($_POST['c'])) ? true : false, ));
Code: Select all
$event['post_data'] = array_merge($event['post_data'], array(
'custom_mode' => $this->request->variable('c', ( (!empty($event['post_data']['custom_mode'])) ? $event['post_data']['custom_mode'] : 0 ), 0),
));
That didn't work either.
Code: Select all
public function posting_modify_submit_post_before(event $event)
{
$event['data'] = array_merge($event['data'], array(
'parent_id' => $event['data']['post_id'],
'custom_mode' => 1,
));
}
// add parent id to database when commenting
public function submit_post_modify_sql_data($event)
{
$sql_data = $event['sql_data'];
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
'parent_id' => $event['data']['custom_mode'],
));
$event['sql_data'] = $sql_data;
}
core.posting_modify_template_vars
-> array $page_data.Code: Select all
public function posting_modify_submission_errors(event $event)
{
$event['post_data'] = array_merge($event['post_data'], array(
'custom_mode2' => $this->request->is_set_post('c') ? 1 : 2,
));
}
public function posting_modify_template_vars(event $event)
{
$event['post_data'] = array_merge($event['post_data'], array(
'custom_mode' => $this->request->is_set_post('c') ? 3 : 4,
));
}
public function posting_modify_submit_post_before(event $event)
{
$event['data'] = array_merge($event['data'], array(
'custom_mode' => $event['post_data']['custom_mode'],
));
}
public function submit_post_modify_sql_data($event)
{
$sql_data = $event['sql_data'];
$sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array(
'parent_id' => $event['data']['custom_mode'],
));
$event['sql_data'] = $sql_data;
}
Code: Select all
public function modify_posting_parameters(event $event)
{
$mode = $event['mode'];
$this->current_mode = 'no';
if($mode == 'custommode')
{
$this->current_mode = 'yes';
$mode = 'quote';
}
$event['mode'] = $mode;
}
Code: Select all
$this->request->variable('HTTP_REFERER', '', false,\phpbb\request\request_interface::SERVER)
$event["post_data']
. Code: Select all
$post_data = $event['post_data'];
// process $post_data
$event['post_data'] = $post_data;
Well it's the only way to actually get the variable I need, because request_var parses the wrong url. Any ideas?
I copied the format from some extension, I can't remember. Thanks for the tip. I understand that but request_var is getting variables from the wrong url (unless I do vardump), I need to use request_var on the original posting.php link that I made in viewtopic somehow...martti wrote: ↑Sat Jun 09, 2018 1:23 pm
- In the event listener, you can not directly assign the result of a function to
$event["post_data']
.
Do:See the "Note" (blue panel) in the documentation.Code: Select all
- You can't depend on the HTTP REFERER, because it is set (or may be not) by the client.
It depends on the event, are more those where you are allowed to do so than the rest.Martti wrote: ↑Sat Jun 09, 2018 4:05 pm In the event listener, you can not directly assign the result of a function to $event["post_data']