Using passed parameters in a form

Extensions, styles and support for everything else about phpBB
Post Reply
Posts: 40
Joined: 23 Jun 2017, 16:03

Using passed parameters in a form


Post by EVO_VV » 17 Mar 2018, 16:52

The object is to be able to move a Post from one Topic to another by clicking a button on the Post instead of having to scroll down to the bottom of the page, clicking on the appropriate tool and then having to scroll through the lists of Posts to tick the one you want to move.
The reason for moving these Posts is to keep the Post & Thanks count for the members which would otherwise be decremented if a delete was used as those counts affect their Rank/Reputation/Permissions

So far I have added the button and it takes me to the correct page with the to_topic_id correctly filled in, so I know the parameters are passed and available.
This comes from a line added in viewtopic.php around 1965 :-
U_DEADPOSTS' => ($auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f={$forum_id}&t={$topic_id}&quickmod=1&action=merge&to_topic_id=6149&tick_post={$row['post_id']}") : '',
For this particular purpose it will always be the same Topic.

My problem is trying to get the relevant post 'Ticked'.
What I want to do is to be able to add something like :- <!-- IF postrow.POST_ID eq tick_post -->checked="checked"<!-- ENDIF -->
to the line in mcp_topic.html around 109
<input type="checkbox" id="post_id_list_select_{postrow.POST_ID}" name="post_id_list[]" value="{postrow.POST_ID}" />

Having searched for examples and tried all the combinations of tick_post with upper case, lower case and ' and " and "{ along with postrow.POST_ID and "{postrow.POST_ID}" but all I ever get is either nothing ticked or all the posts ticked.

Either I have not got the syntax correct or it is not possible to use that passed parameter in this way.
Or is there something else I am missing ?

User avatar
mChat developer
Posts: 895
Joined: 06 Oct 2016, 09:56
Location: Germany

Re: Using passed parameters in a form


Post by kasimi » 18 Mar 2018, 10:28

The tick_post value is available in your PHP code, and you want to use the value in the HTML file. What's the glue between the two? The template service: in includes/mcp/mcp_main.php, look for the action you're working with and assign the value to the template:

Code: Select all

$template->assign_var('TICK_POST', $request->variable('tick_post', 0));
Now you can use <!-- IF postrow.POST_ID eq TICK_POST --> in the HTML file. (The coding guidelines suggest to use all upper-case template variable names.)

Posts: 40
Joined: 23 Jun 2017, 16:03

Re: Using passed parameters in a form


Post by EVO_VV » 18 Mar 2018, 13:32

Ahhhh, now I see.
I had assumed that as the to_topic_id was already available that it came from the U_DEADPOSTS.

It is actually in mcp_topic.php that I have to assign the variable and add it to the Template.
I'll go and test that on my server.

Many thanks for pointing me in the right direction.

:beer: :beer: :beer:

Yep, now working as intended.

Thank you again for your valuable assistance.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest