Jump to content

confusion with my template


chmpdog

Recommended Posts

Hello World,

 

On my site I have a template system that I set up, but I have come to a major problem. I cant write in the headers. I have fiured out why, but I dont know how to fix it, so I thought maybe someone knows an easy way out.

 

My template consists of an index page, the duty of the index page is to include all the template files, and it also includes the file that determines what page the user is on (and what page-contents to include) based on $_GET info. In this file I have set up functions for all the main parts of my page [iE contents_title(), or main_content()] and I take those functions and place them in the template file I included earlier.

 

But that is where the problem arose. In order to get the header data (like title, and meta tags) main_content() has to be run, because the title variable is located inside that (I cant move the var location because the content may need to change based on user input.) . If I put contents_title() after main_content() everything works, but I cant that because the headers have already been sent by the time main_content() has been executed.

 

So Is there any way to pick out several variables from this function, before the headers load?

 

Thank you very much,

CHARLES

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/148486-confusion-with-my-template/
Share on other sites

you can add the pages but using the ob_start method not recommended but it will work.

 

example only.

 

all it does is stop a header error,

also if you use require_once() from those pages with header info

might all so stop header error's.

 

try.

<?php ob_start();

session_start(); // if session's used.

ob_flush()  //<<< bottom of the new template page.
?>

 

like i say it a quick fix not recommended.

 

It time to think how you can re design your templates in the future.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.