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: 697
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 » 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
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][BETA] Sticky Ad || [3.2][RC] Show User Activity ||
[3.2][DEV] User Delete Topics

User avatar
caiocald
Registered User
Posts: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » 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

User avatar
Toxyy
Registered User
Posts: 697
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 » Thu Dec 20, 2018 2:15 am

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!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][BETA] Sticky Ad || [3.2][RC] Show User Activity ||
[3.2][DEV] User Delete Topics

User avatar
caiocald
Registered User
Posts: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 2:20 am

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: 697
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 » 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.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][BETA] Sticky Ad || [3.2][RC] Show User Activity ||
[3.2][DEV] User Delete Topics

User avatar
caiocald
Registered User
Posts: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 3:21 am

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: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 3:25 am

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: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 3:54 am

i try:

Code: Select all

<input type="hidden" name="topic_id" value="<?= echo"$_GET['t']";?>">
but no... :(

User avatar
caiocald
Registered User
Posts: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 5:01 am

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
Jr. Extension Validator
Posts: 1051
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

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

Post by mrgoldy » 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).
phpBB Studio / ''Proud member of the Studio"

User avatar
caiocald
Registered User
Posts: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 9:35 am

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
Jr. Extension Validator
Posts: 1051
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

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

Post by mrgoldy » 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
		}
	}
}
phpBB Studio / ''Proud member of the Studio"

User avatar
canonknipser
Registered User
Posts: 2018
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 » 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 ...)
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: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 7:01 pm

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: 60
Joined: Mon Feb 26, 2018 9:32 pm
Location: Brasil
Name: B!
Contact:

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

Post by caiocald » Thu Dec 20, 2018 7:11 pm

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”