Welcome to WebmasterWorld Guest from 54.224.253.82

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Working with PHP templates

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

Junior Member

5+ Year Member

joined:Apr 23, 2009
posts: 54
votes: 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!

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


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

Junior Member

5+ Year Member

joined:Apr 23, 2009
posts: 54
votes: 0


Hi Andrew,

I have tried both as well as require_once

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

Administrator

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

joined:July 31, 2003
posts:12537
votes: 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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members