homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Working with PHP templates

5+ Year Member

Msg#: 4198391 posted 8:53 am on Sep 8, 2010 (gmt 0)

I have a site made in php with a header and footer file to template it and I have a require at the beginning of each of the site files for header.php and one at the end for footer.php.

This works really well for static pages and is something I have used on many occasions.

The challenge I am having is integrating any kind of third party application and getting it to work with the existing template.

For example I have a forum, FAQ and news script installed in sub directories of the web root on the site and using the above method I get lots of "Warning: Cannot modify header information - headers already sent type" errors.

I then decided to take the HTML from my template header and footer and paste these directly into the actual forum, FAQ and news template files which works well on the surface, but my site is quite dynamic and in my usual footer.php, for example, there is a call to the news script which displays the 3 most recent news topics and this then does not work (i.e it only ever shows the static HTML pasted).

Additionally, if I change the overall site template then I need to remember to change it in the forums as well which is a bit of a pain!

Is there an easy way of using an existing ../header.php and ../footer.php file so when I change the one header.php file it changes for all pages and also so the dynamic content in the those files is shown on the third party pages as well?

For the record I am a newbie and very wet behind the ears on PHP and am very slowly teaching myself as I chug along!




WebmasterWorld Senior Member 5+ Year Member

Msg#: 4198391 posted 10:24 pm on Sep 8, 2010 (gmt 0)

How are you including the header and footer? include() require()?


5+ Year Member

Msg#: 4198391 posted 6:02 am on Sep 9, 2010 (gmt 0)

Hi Andrew,

I have tried both as well as require_once



WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4198391 posted 11:29 am on Sep 28, 2010 (gmt 0)

Don't forget you can always use output buffering to prevent output from being written. You can store the output in a variable and manipulate it prior to writing it out to the browser.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved