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

Re: Include php file in html template?

Post by aeneas1 » Sun Jan 27, 2019 8:06 pm

interestingly i now get the following error when i try to use:

Code: Select all

<!-- INCLUDEPHP plugin_iframe.php -->
i was getting a blank page with just the navbar showing, but now i get a completely blank page with this error message:

Code: Select all

Fatal error: Cannot redeclare deregister_globals() (previously declared in /home/gametim9/public_html/includes/startup.php:36) in /home/gametim9/public_html/includes/startup.php on line 85
here's my php file:

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();
?>

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

Re: Include php file in html template?

Post by Lumpy Burgertushie » Sun Jan 27, 2019 8:27 pm

sorry, I have no idea what that php file is supposed to do. however, it looks to me like it would probably create a new phpbb page where you insert it. I mean the whole page not just your iframe.

also, because you have all that phpbb files included in it, it will be calling those things twice because your index.php file is already calling them all.


I suggest you just use the include iframe statement that is currently working.


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 » Sun Jan 27, 2019 9:37 pm

Lumpy Burgertushie wrote:
Sun Jan 27, 2019 8:27 pm
sorry, I have no idea what that php file is supposed to do. however, it looks to me like it would probably create a new phpbb page where you insert it. I mean the whole page not just your iframe.
yes, it creates this page:

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

but i don't know if the code in the php file is correct in that i just used a php "template" of sorts to create it... it displays fine (if you follow the above link), buti'm wondering if there's something in the code that prevents it from displaying using <!--INCLUDEPHP....
Lumpy Burgertushie wrote: also, because you have all that phpbb files included in it, it will be calling those things twice because your index.php file is already calling them all.
what code can i remove from the file to prevent this? or is there a php template i can use that would be better?
Lumpy Burgertushie wrote: I suggest you just use the include iframe statement that is currently working.
if i can't get <!---INCLUDEPHP to work then i guess i'll have to use an iframe, prob is iframes load slow (the php file actually loads very fast when not iframed) and i've had members complain that their system blocks iframes...

btw the site i have been linking to is my test board, fwiw.

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

Re: Include php file in html template?

Post by Lumpy Burgertushie » Mon Jan 28, 2019 2:49 am

post the actual php that you are putting in the iframe html file

the problem is the way you are trying to do it is duplicating the php at least twice and that is not how it works.

what you need is the actual php that creates that page. you create a simple php file with that code in it. you do not need to create a phpbb php file that includes a html file that includes html and php etc. etc.


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 » Mon Jan 28, 2019 4:12 am

Lumpy Burgertushie wrote:
Mon Jan 28, 2019 2:49 am
post the actual php that you are putting in the iframe html file

the problem is the way you are trying to do it is duplicating the php at least twice and that is not how it works.

what you need is the actual php that creates that page. you create a simple php file with that code in it. you do not need to create a phpbb php file that includes a html file that includes html and php etc. etc.


robert
yes robert, that seems to be the case, exactly what's happening....

here's my current setup:

1. all of the components (html, css, js) for the landing page (banner) that i want to display are located in it's own folder (styles/phpbb-theme/theme/countdown/image/).

2. this folder contains an "index.html" file that has the code, which i'm referencing from an html file that i created and placed in the styles/phpbb-theme/template/ folder, the file is named "plugin_iframe.html" and contains the following code:

Code: Select all

<!-- INCLUDE ../theme/countdown/image/index.html -->
3. the php file i created (plugin_iframe.php) references the above file (plugin_iframe.html) - i would have rather had the php file directly reference the landing page's index.html file but i didn't know how to write a path to that location.

4. the iframe code i've embedded in the overall_header file is:

Code: Select all

<iframe style="width: 100%; height: 1000px; border: none;" src="https://www.gametimememories.com/plugin_iframe.php" onload="window.parent.scrollTo(0,0)" scrolling="no">Iframes not supported</iframe>
5. the plugin_iframe.php code is:

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();
?>

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

Re: Include php file in html template?

Post by Lumpy Burgertushie » Mon Jan 28, 2019 4:49 am

ok, now I see what you are doing.

you don't need any php or any include php for this at all.

you are not using any php code in your countdown page at all.

if you are trying to simply display that countdown timer then you have way more code in that index.html file than you need for just that.
I can't figure out what all that code is supposed to be doing. it looks like a sales page from themeforest.net for web site templates etc.

you have links back to the flatboots theme folder , links to multiple scripts, etc. etc. etc

none of which are working propely from what I can tell.

so, at this point I still say to keep using the iframe because unless you start completely over I don't think you will get it to work any other way.

luck,
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 » Mon Jan 28, 2019 5:39 am

Lumpy Burgertushie wrote:
Mon Jan 28, 2019 4:49 am
ok, now I see what you are doing.

you don't need any php or any include php for this at all.

you are not using any php code in your countdown page at all.

if you are trying to simply display that countdown timer then you have way more code in that index.html file than you need for just that.
I can't figure out what all that code is supposed to be doing. it looks like a sales page from themeforest.net for web site templates etc.

you have links back to the flatboots theme folder , links to multiple scripts, etc. etc. etc

none of which are working propely from what I can tell.

so, at this point I still say to keep using the iframe because unless you start completely over I don't think you will get it to work any other way.

luck,
robert
robert, can't tell you how much i appreciate your trying to help me sort this out....

the landing page's index.html file has a lot of links (css, js, etc.) to it's own sub-folders, not to the phpbb-theme's (flatboots) files (as far as i can tell), and all of the links seem to be working fine, i.e. if i delete a link the landing page's corresponding feature stop working.

yes, i want a countdown (which i could get anywhere and easily add to my existing theme), but the landing page has a lot of other features that i'm interested in, sliding hero images, two hidden panels that can act as a storyboard etc..

anyway, in the past i've had great luck adding these sort of things (custom navbars, video headers, large animated header images, etc.) by just using <--include html.file, no fuss no muss, but this thing has so much common css that my phbb-theme's css takes over and renders it pretty useless, it also conflicts with a lot of my theme's css code...

by using php i could pretty much sandbox the thing, as can be seen using the direct link the php page, my theme's css remains untouched, and so does the landing page's css and js stuff...

just wish i could get <--includephp to work because the more i try to get the iframe to look ok, the more i realize the iframe's limitations, including slow loading.

anyway, thanks again.

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

Re: Include php file in html template?

Post by Lumpy Burgertushie » Mon Jan 28, 2019 6:28 am

well, the problem is that you are not using any php at all. there is no php code in the counter or any other part of that page that you are trying to include.
if you try to use a phpbb based php page as you have done, then , as mentioned before it duplicates all the php from phpbb over and over and won't work.

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 » Mon Jan 28, 2019 7:26 am

Lumpy Burgertushie wrote:
Mon Jan 28, 2019 6:28 am
well, the problem is that you are not using any php at all. there is no php code in the counter or any other part of that page that you are trying to include.
if you try to use a phpbb based php page as you have done, then , as mentioned before it duplicates all the php from phpbb over and over and won't work.

robert
yeah, i actually thought i was onto something after googling/finding more info on the subject circa 2008-2010 (ha ha), but in the end the sitches discussed weren't the same as mine, and it's now clear that ii didn't find anything because of what you've pointed out... anyway, gonna play around with iframing it some more, i've figured a few iframe things out that just might make it looks as seamless as i wanted, like what i was hoping for by adding the php file directly, however i don't think i'm going to be able to get past the slow iframe loading, we'll see... anyway robert, thanks a ton for your help!

Nick225
Registered User
Posts: 103
Joined: Sat Nov 24, 2018 7:48 pm

Re: Include php file in html template?

Post by Nick225 » Mon Feb 18, 2019 6:21 am

You can include any file in your template.
Place the file in your root directory (where faq.php is located)
Here is what I do

Code: Select all

<!-- PHP -->
global $phpbb_root_path; 
include($phpbb_root_path . 'whatever_file.ext');
<!-- ENDPHP -->
It always works for me.

User avatar
Mick
Support Team Member
Support Team Member
Posts: 20837
Joined: Fri Aug 29, 2008 9:49 am
Location: Watching cricket - probably.

Re: Include php file in html template?

Post by Mick » Mon Feb 18, 2019 9:02 am

Filesystem.php and filesystem.php are not the same thing if that's anything to do with it.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: Brf, janus_zonstraal, Lumpy Burgertushie and 4 guests