Page 1 of 1

Can I share phpBB variables with included PHP file?

Posted: Sat Jul 01, 2017 3:50 pm
by schwim
Hi there everyone,

I'd like to share variables like $user->data['username'] between the php page and a PHP file included in the template. Is there a way to do this other than duplicating the session system inside the included file? Is there some way to pass these variables on to the included script?

Thanks for your time!

Re: Can I share phpBB variables with included PHP file?

Posted: Sun Jul 02, 2017 8:53 pm
by schwim
Bumping in hopes of some help. I apologize if this is frowned upon.

Re: Can I share phpBB variables with included PHP file?

Posted: Sun Jul 02, 2017 9:25 pm
by Toxyy
How are you wanting to use the variable?

Re: Can I share phpBB variables with included PHP file?

Posted: Sun Jul 02, 2017 9:42 pm
by schwim
Toxyy wrote:
Sun Jul 02, 2017 9:25 pm
How are you wanting to use the variable?
In a myriad of ways, to be honest. I'm planning on many uses but if a single example is a necessity, I've got a member map that I'm including on certain pages via phpinclude in the template and that included file requires the variable for nearby members and points of interest.

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 3:02 pm
by schwim
Bumping again in hopes of some knowledge on the matter.

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 4:57 pm
by javiexin
Impossible without more information.
And, if you are planning to use it "for a myriad of things" then you should really learn how to program extensions, and not try to hack the code.

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:39 pm
by schwim
If anyone else can answer the simple question of "Can $user->data['username'] be passed to a PHP file included via the template without requiring more information, it would be greatly appreciated.

Thanks for your time!

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:45 pm
by david63
How do you include a PHP file via a template?

And in answer to
schwim wrote:
Tue Jul 04, 2017 5:39 pm
... without requiring more information,
Not without a crystal ball

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:49 pm
by Toxyy
david63 wrote:
Tue Jul 04, 2017 5:45 pm
How do you include a PHP file via a template?
You can't, only html files.
Can $user->data['username'] be passed to a PHP file included via the template without requiring more information
You can include username, just depends on what page you're on and what template event you're working with.

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:49 pm
by schwim
david63 wrote:
Tue Jul 04, 2017 5:45 pm
How do you include a PHP file via a template?

Code: Select all

<!-- INCLUDEPHP ./extras/test.php -->
And I managed to figure out how to do it. Thanks to everyone for the help!

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:51 pm
by Toxyy
schwim wrote:
Tue Jul 04, 2017 5:49 pm
david63 wrote:
Tue Jul 04, 2017 5:45 pm
How do you include a PHP file via a template?

Code: Select all

<!-- INCLUDEPHP ./extras/test.php -->
And I managed to figure out how to do it. Thanks to everyone for the help!
And that actually works for you?

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 5:54 pm
by schwim
Yes, after enabling "Allow PHP in templates" in the ACP, it works just fine.

Re: Can I share phpBB variables with included PHP file?

Posted: Tue Jul 04, 2017 6:21 pm
by Toxyy
Well, I learned something today. Glad you got it working.