Welcome to WebmasterWorld Guest from 23.23.46.20

Forum Moderators: coopster & jatar k

Working with PHP templates

   
8:53 am on Sep 8, 2010 (gmt 0)

5+ Year Member



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!

Jase
10:24 pm on Sep 8, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



How are you including the header and footer? include() require()?
6:02 am on Sep 9, 2010 (gmt 0)

5+ Year Member



Hi Andrew,

I have tried both as well as require_once

Thanks
Jason
11:29 am on Sep 28, 2010 (gmt 0)

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



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month