Include php file in html template?

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
aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Include php file in html template?

Post by aeneas1 » Fri Jan 25, 2019 10:16 pm

have googled the topic but still can't seem to get it to work...

> the php file i want to include is in my root directory (public_html)
> i've tried several variations of <!-- INCLUDEPHP myfile.php --> such as ./myfile.php, no love
> i've activated php in the acp security settings

i also came across a post that suggested adding the following altho i'm not exactly sure where to add it, i.e. which file and where in the file.

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
any help would be appreciated!

User avatar
Lumpy Burgertushie
Registered User
Posts: 65729
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Include php file in html template?

Post by Lumpy Burgertushie » Fri Jan 25, 2019 11:13 pm

we need to see the php in the file you are trying to include and the file you are trying to include it in.

copy and paste them into code tags here.

robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sat Jan 26, 2019 12:32 am

Lumpy Burgertushie wrote:
Fri Jan 25, 2019 11:13 pm
we need to see the php in the file you are trying to include and the file you are trying to include it in.

copy and paste them into code tags here.

robert
thanks robert...

here's the php file, just used another php file as the framework and edited it - it references an html file (plugin_iframe.html)... the file i'm trying to include it in is the overall_header.html file.

worth noting, at first i used "INCLUDE" for the htnl file (as opposed to the php file) and it worked as expected, thing is this particular file i'm working with has a lot of css (html, body, container, etc.) that seems to override a lot of my site's css when i use "INCLUDE" html (it's a purchased landing page), but when i view it standalone (mysite/plugin_iframe.php) it works perfectly and my site's css is unaffected, hope that makes sense?

i also tried to to i-frame the plugin_iframe.php page (in my overall_header.html file) and it seems to work ok, it doesn't override css, but it would require some elbow grease for it to display just right.

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewtopic'); 

page_header('iframe');
// Set up the Navlinks for the forums navbar
$template->assign_block_vars('navlinks', array(
'FORUM_NAME' => 'IFRAME',
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}plugins_iframe.$phpEx"))
);

$template->set_filenames(array(
    'body' => 'plugin_iframe.html',
));

page_footer();
?>

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sat Jan 26, 2019 9:04 pm

any thoughts?

User avatar
Lumpy Burgertushie
Registered User
Posts: 65729
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Include php file in html template?

Post by Lumpy Burgertushie » Sat Jan 26, 2019 9:15 pm

I can't figure out what you are trying to do.

if you want to include php in a template file you use the

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
if you want to include a php file you use the

Code: Select all

<!-- INCLUDEPHP myfile.php -->
there is no need to use a php file to include a iframe or whatever you are trying to do.

robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sat Jan 26, 2019 9:45 pm

Lumpy Burgertushie wrote:
Sat Jan 26, 2019 9:15 pm
I can't figure out what you are trying to do.

if you want to include php in a template file you use the

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
if you want to include a php file you use the

Code: Select all

<!-- INCLUDEPHP myfile.php -->
there is no need to use a php file to include a iframe or whatever you are trying to do.

robert
first, thanks robert...

yeah, i think the way i named my files may be causing some confusion i terms of what i'm wanting....

i simply want to add/include a php fle/page that i've created to the overall header file, much like one would do with an html file as follows:

Code: Select all

<!-- INCLUDE ../theme/myfile/file.html -->
i thought that if this couldn't be done, perhaps i could i-frame the php file/page i created into the overall header file....

anyway, where would i add the following code? to which file and where in the file?

Code: Select all

<!-- PHP -->
echo "hello!";
<!-- ENDPHP -->
thanks again.

User avatar
Lumpy Burgertushie
Registered User
Posts: 65729
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Include php file in html template?

Post by Lumpy Burgertushie » Sat Jan 26, 2019 10:15 pm

probably in the overall_header file but it really depends on where you want the php to execute.

exactly what are you trying to do with the php code.

what is the exact php you are going to include.

no offense but nothing you have showed us so far makes any sense at all.

please be specific.


robert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sat Jan 26, 2019 10:36 pm

Lumpy Burgertushie wrote:
Sat Jan 26, 2019 10:15 pm
probably in the overall_header file but it really depends on where you want the php to execute.

exactly what are you trying to do with the php code.

what is the exact php you are going to include.

no offense but nothing you have showed us so far makes any sense at all.

please be specific.


robert
here's my php file:

https://www.gametimememories.com/plugin_iframe.php

i want to add it to my overall header file, in between the navbar and forum body, so that when i load my forum the navbar displays as usual, then the above php file, then, finally, the forum body, much in the same way you would add a large animated hero image/banner to the top of your forum using <!-- INCLUDE ../theme/hero-banner/index.html --> or the like...

hope this makes sense.

User avatar
Lumpy Burgertushie
Registered User
Posts: 65729
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Include php file in html template?

Post by Lumpy Burgertushie » Sat Jan 26, 2019 11:06 pm

is this your site: https://www.gametimememories.com/

if so, then it is already there and shows just fine.

rob ert
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sat Jan 26, 2019 11:12 pm

Lumpy Burgertushie wrote:
Sat Jan 26, 2019 11:06 pm
is this your site: https://www.gametimememories.com/

if so, then it is already there and shows just fine.

rob ert
it shows because i went ahead and iframed the php file, i.e. i added this to the overall_header file:

Code: Select all

<iframe style="width: 100%; height: 1200px; overflow: hidden;" src="https://www.gametimememories.com/plugin_iframe.php" width="100" height="100" scrolling="no">Iframes not supported</iframe> 
was hoping there would be a way to add the php file directly using "INCLUDEPHP" rather than iframing it because i've been told i-frames can be rejected by some browsers depending on the user settings.... but if that's not possible i can live the i-frame.

User avatar
Lumpy Burgertushie
Registered User
Posts: 65729
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Include php file in html template?

Post by Lumpy Burgertushie » Sat Jan 26, 2019 11:24 pm

try replacing your iframe include with this:
<!-- INCLUDEPHP https://www.gametimememories.com/plugin_iframe.php -->
I am available for custom work on a donation basis. Please send me a PM with your needs.

Premium phpBB 3.2 Styles by PlanetStyles.net

OK, so what's the speed of dark?

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sun Jan 27, 2019 1:26 am

Lumpy Burgertushie wrote:
Sat Jan 26, 2019 11:24 pm
try replacing your iframe include with this:
<!-- INCLUDEPHP https://www.gametimememories.com/plugin_iframe.php -->
yes, i tried that last night, no love, i get this error:

Code: Select all

/Filesystem.php:215 Stack trace: #0 /home/gametim9/public_html/phpbb/template/twig/loader.php(107): Twig_Loader_Filesystem->findTemplate('https:/www.game...') #1 /home/gametim9/public_html/vendor/twig/twig/lib/Twig/Loader/Filesystem.php(139): phpbb\template\twig\loader->findTemplate('https://www.gam...') #2 /home/gametim9/public_html/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code(387): Twig_Loader_Filesystem->getCacheKey('https://www.gam...') #3 /home/gametim9/public_html/vendor/twig/twig/lib/Twig/Template.php(387): __TwigTemplate_35c52f7ac15893b514c59870db00c7fc7b0d11a1f7b202dca3687ffbfcb0c2a9->doDisplay(Array, Array) #4 /home/gametim9/public_html/vendor/twig/twig/lib/Twig/Template.php(355): Twig_Te in /home/gametim9/public_html/vendor/twig/twig/lib/Twig/Loader/Filesystem.php on line 215
do i have the path right? my php file is in the public_html folder along with the other phpbb php files.

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sun Jan 27, 2019 10:24 am

any other thoughts re how i can get this to work? any help would be very much appreciated.

User avatar
david63
Jr. Extension Validator
Posts: 15442
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Include php file in html template?

Post by david63 » Sun Jan 27, 2019 10:35 am

aeneas1 wrote:
Sun Jan 27, 2019 10:24 am
any other thoughts re how i can get this to work? any help would be very much appreciated.
Have you considered adding it as an extension?
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

aeneas1
Registered User
Posts: 448
Joined: Wed Jan 27, 2016 5:58 pm

Re: Include php file in html template?

Post by aeneas1 » Sun Jan 27, 2019 11:07 am

david63 wrote:
Sun Jan 27, 2019 10:35 am
aeneas1 wrote:
Sun Jan 27, 2019 10:24 am
any other thoughts re how i can get this to work? any help would be very much appreciated.
Have you considered adding it as an extension?
thanks for the reply david63 but that's above my pay grade, i don't know how to go about adding it as an extension.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 3 guests