How to Capturing the topic_id variable inside a form action (controller with route)? [resolved]

Discussion forum for Extension Writers regarding Extension Development.
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by Toxyy »

caiocald wrote: Thu Dec 20, 2018 1:12 am

Code: Select all

 $topic_id = $this->request->variable('topic_id',0);
Try t instead of topic_id
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

Toxyy wrote: Thu Dec 20, 2018 1:29 am
caiocald wrote: Thu Dec 20, 2018 1:12 am

Code: Select all

 $topic_id = $this->request->variable('topic_id',0);
Try t instead of topic_id

Code: Select all

$topic_id = $this->request->variable('t',0);
return 0
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by Toxyy »

caiocald wrote: Thu Dec 20, 2018 1:58 am
Toxyy wrote: Thu Dec 20, 2018 1:29 am
caiocald wrote: Thu Dec 20, 2018 1:12 am

Code: Select all

 $topic_id = $this->request->variable('topic_id',0);
Try t instead of topic_id

Code: Select all

$topic_id = $this->request->variable('t',0);
return 0
When are you calling formulariopontuacao()?

Also try: $this->request->variable('t', '');
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

When are you calling formulariopontuacao()?
When the user clicks the submit form button
Also try: $this->request->variable('t', '');

Code: Select all

$topic_id = $this->request->variable('t', '');
return ''
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by Toxyy »

caiocald wrote: Thu Dec 20, 2018 2:20 am When the user clicks the submit form button
Show me this in your github, likely you'll need to add the topic id into the form itself with a hidden input, then you'll be able to pull the data with a request var.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

Toxyy wrote: Thu Dec 20, 2018 3:11 am
caiocald wrote: Thu Dec 20, 2018 2:20 am When the user clicks the submit form button
Show me this in your github, likely you'll need to add the topic id into the form itself with a hidden input, then you'll be able to pull the data with a request var.
OMG

THATS THE PONIT!

I'll try and tell you

link for my github https://github.com/caiocal/Essay-Extens ... r/main.php
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

how would I specify the value of the imput?

Code: Select all

<input type="hidden" name="topic_id" value="">
thankssssssssssssssssssssssssssssssss
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

i try:

Code: Select all

<input type="hidden" name="topic_id" value="<?= echo"$_GET['t']";?>">
but no... :(
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

definitely does not work.

I enabled the php include in ACP panel security and it still failed.

Code: Select all

<!-- PHP -->echo "$_GET['t']";<!-- ENDPHP -->
It's ... Finishing this extension is going to be a fight ...
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by mrgoldy »

All nice and dandy it is in the current URL, but if it is not in your form action URL you will not be able to request it.
So you either have to append it to your form action's URL or add a hidden input field with the current topic identifier as a value.
Then upon submission you can request it with $topic_id = $this->request->variable('t', 0); (where t is the name attribute of your input field or parameter).
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

mrgoldy wrote: Thu Dec 20, 2018 9:08 am All nice and dandy it is in the current URL, but if it is not in your form action URL you will not be able to request it.
So you either have to append it to your form action's URL or add a hidden input field with the current topic identifier as a value.
Then upon submission you can request it with $topic_id = $this->request->variable('t', 0); (where t is the name attribute of your input field or parameter).
Mr. Goldy

I still could not sleep trying to figure it out. I know it seems to be an easy thing. But I can not.
I tried the request. I tried the hidden imput, but it just will not.
you could analyze my code? I only lack this to continue the construction (and maybe finish it) my extension.
Is it not recognizing the url because of lightbox?
Please help me. I'll freak out
Last edited by caiocald on Thu Dec 20, 2018 9:46 am, edited 1 time in total.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by mrgoldy »

There is no way to "analyze" your code, as you do not have a link to your GitHub repository.
And please do not see this as an invite to attach a zip here or in a private message.

And well, what can I say, if you can not manage to request an input variable from a form, there is a long road ahead of you.
Anyways, this is the best example I can give you:

Code: Select all

<form action="post" action="{{ U_YOUR_FORM_ACTION }}">
	<!-- YOUR_FORM_ACTION should include &t=5
		or you can use an hidden input like below -->
	<input name="t" type="hidden" value="5">
	
	...
	
	<input class="button1" id="submit" name="submit" type="submit" value="{{ lang('SUBMIT') }}">
</form>

Code: Select all

<?php

namespace vendor\extension\controller;

class main_controller
{
	/** @var \phpbb\request\request */
	protected $request;
	
	public function __construct(\phpbb\request\request $request)
	{
		$this->request = $request;
	}
	
	public function handle()
	{
		// if the form is submitted
		if ($submit = $this->request->is_set_post('submit'))
		{
			// request the form variables
			$topic_id = $this->request->variable('t', 0);
			
			// Do your thing
		}
	}
}
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Help with the adaptation of a tool in php for phpbb extension

Post by canonknipser »

I would suggest to try the skeleton tool to check out the way extension coding work in their different context (acp, ucp, mcp, standard page ...)
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

mrgoldy wrote: Thu Dec 20, 2018 2:51 pm There is no way to "analyze" your code, as you do not have a link to your GitHub repository.
And please do not see this as an invite to attach a zip here or in a private message.

And well, what can I say, if you can not manage to request an input variable from a form, there is a long road ahead of you.
Anyways, this is the best example I can give you:

Code: Select all

<form action="post" action="{{ U_YOUR_FORM_ACTION }}">
	<!-- YOUR_FORM_ACTION should include &t=5
		or you can use an hidden input like below -->
	<input name="t" type="hidden" value="5">
	
	...
	
	<input class="button1" id="submit" name="submit" type="submit" value="{{ lang('SUBMIT') }}">
</form>

Code: Select all

<?php

namespace vendor\extension\controller;

class main_controller
{
	/** @var \phpbb\request\request */
	protected $request;
	
	public function __construct(\phpbb\request\request $request)
	{
		$this->request = $request;
	}
	
	public function handle()
	{
		// if the form is submitted
		if ($submit = $this->request->is_set_post('submit'))
		{
			// request the form variables
			$topic_id = $this->request->variable('t', 0);
			
			// Do your thing
		}
	}
}
return 0

I can get all the variables I need. The only thing that does not work is topic_id

I posted the link from my repository in the first post of that thread
User avatar
caiocald
Registered User
Posts: 213
Joined: Mon Feb 26, 2018 9:32 pm
Name: B!

Re: Help with the adaptation of a tool in php for phpbb extension

Post by caiocald »

canonknipser wrote: Thu Dec 20, 2018 6:11 pm I would suggest to try the skeleton tool to check out the way extension coding work in their different context (acp, ucp, mcp, standard page ...)
Hi, Canonknipser

I'm using his model as a reference and it has helped me a lot.
But for this case of the topic, I could not find anything.

Thanks for the tip
Post Reply

Return to “Extension Writers Discussion”