Forum Moderators: coopster

Message Too Old, No Replies

PHP Template System Help

         

stidj

5:06 am on Aug 10, 2005 (gmt 0)

10+ Year Member



Hi guys,

I'm trying to implement this template system for my site:
[codewalkers.com...]

I keep getting header error conflicts so let me do my best to explain what is happening.

First of all I have one function that ultimately will return all of the page content that would need to be put out. It is assigned to one variable, nothing is output during the execution of that function EXCEPT cookies are set.

This is where it becomes a pain.....

From the file where I call this function that returns the output to a variable a few things need to happen.

#1 I need to send a few header() commands and I also need to call the function that will parse my output.

I get header errors because the script content that would execute the setcookie() functions is not called until the parser outputs some data.

Sorry if this sounds confusing but is there a way to make this all play happily or do I need a custom template system?

Thanks guys

mcibor

9:23 am on Aug 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can't you put the setcookie before output? If not, then you got yourself a bad template.

There's no php way to set a cookie after sth is sent to user. The only remaining way is to set the cookie via JavaScript.
Search the hotscripts [hotscripts.com] for js cookies.

Best regards
Michal CIbor

stidj

1:14 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



Well the problem is with the template. Say I don't create a new instance of Page.......then the set cookie is set first.
But the class.php file which you include first automatically outputs something first.

stidj

2:20 pm on Aug 10, 2005 (gmt 0)

10+ Year Member



I fixed it by simply moving the inclusion of class.php after I call the function that would generate the output page (which is the same function that would send cookies).

Yay :)