Can I share phpBB variables with included PHP file?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

Can I share phpBB variables with included PHP file?

Post by schwim » Sat Jul 01, 2017 3:50 pm

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!

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » Sun Jul 02, 2017 8:53 pm

Bumping in hopes of some help. I apologize if this is frowned upon.

User avatar
Toxyy
Registered User
Posts: 702
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

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

Post by Toxyy » Sun Jul 02, 2017 9:25 pm

How are you wanting to use the variable?
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

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » Sun Jul 02, 2017 9:42 pm

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.

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » Tue Jul 04, 2017 3:02 pm

Bumping again in hopes of some knowledge on the matter.

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

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

Post by javiexin » Tue Jul 04, 2017 4:57 pm

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.

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » Tue Jul 04, 2017 5:39 pm

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!

User avatar
david63
Registered User
Posts: 16718
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

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

Post by david63 » Tue Jul 04, 2017 5:45 pm

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
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
Toxyy
Registered User
Posts: 702
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

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

Post by Toxyy » 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?
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.
Last edited by Toxyy on Tue Jul 04, 2017 5:50 pm, edited 1 time in total.
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

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » 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!

User avatar
Toxyy
Registered User
Posts: 702
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

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

Post by Toxyy » Tue Jul 04, 2017 5:51 pm

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?
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

schwim
Registered User
Posts: 120
Joined: Sat Jun 04, 2005 8:03 am

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

Post by schwim » Tue Jul 04, 2017 5:54 pm

Yes, after enabling "Allow PHP in templates" in the ACP, it works just fine.

User avatar
Toxyy
Registered User
Posts: 702
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

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

Post by Toxyy » Tue Jul 04, 2017 6:21 pm

Well, I learned something today. Glad you got it working.
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

Post Reply

Return to “phpBB Custom Coding”