chmpdog Posted March 8, 2009 Share Posted March 8, 2009 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 More sharing options...
redarrow Posted March 8, 2009 Share Posted March 8, 2009 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. Link to comment https://forums.phpfreaks.com/topic/148486-confusion-with-my-template/#findComment-779744 Share on other sites More sharing options...
chmpdog Posted March 8, 2009 Author Share Posted March 8, 2009 Thanks for the post, but im not getting a header error, the real problem is I cant display the page title and meta info until after main_content() has executed. Link to comment https://forums.phpfreaks.com/topic/148486-confusion-with-my-template/#findComment-779750 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.