Topic: Integration Issue with exit ($tpl_main);

I'm currently in the process of integrating punbb with a project I've been working on for a while.  The integration has gone fairly smooth until now.  I'm having a problem with line 161 of footer.php where "exit ($tpl_main);" is called.  Initially I thought I could simply change this to "echo ($tpl_main);" however this is not working.  For most cases this works however there are a few where additional code is called.  You can see an example of this if you change this line of code to echo, then click the "forgot password" link.  You will not see a login box under the "Request Password" box.  There are a number of other cases where additional code is executed however this is the easiest to see.

This would not be an issue however I need to include some of my own content below the punbb pages and the exit does not allow that.  Any help would be appreciated.

Re: Integration Issue with exit ($tpl_main);

Just put your content in a placeholder in main.tpl (<mycontent> or something) and replace that in footer.php smile

Re: Integration Issue with exit ($tpl_main);

I thought about this however it's not really an option.  My application already does the templating and the punbb forum is a part of the template.  Also, not every page called has a punbb aspect to it.  I need to maintain a clean seperation between the two apps as well.  I guess I'm just a bit bothered by the poor design of calling an exit numerous times in the application when it would have easily been designed to exit silently and these type of problems could be avoided.

If anyone has any ideas I would very much like to hear them.

4 (edited by Smartys 2006-06-13 18:20)

Re: Integration Issue with exit ($tpl_main);

Aha
The issue there is caused because footer.php is called in the middle of the page within the if statement and the rest of the page isn't within the else statement (so the page "relies" on the exit to keep it from calling the rest of the page and footer.php again)
Just do

// Spit out the page
echo $tpl_main;
[insert your code here]
exit;

Keeping in mind, of course, that you are creating invalid HTML that way without some editing of main.tpl (which I assume you already did)

Re: Integration Issue with exit ($tpl_main);

Thanks for the help, I found a solution.  Since I'm on php5 I just replace all the exit calls in punbb with a thrown exception.  Then the exception will be caught in my application, allowing the rest of my code to be executed.  It will appear the same to punbb because the stack of the application will be aborted, but not the stack of my application.  In general however, it is really bad form to call exits in any application when the code could silently die.

Re: Integration Issue with exit ($tpl_main);

Wouldn't a return do the same?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Integration Issue with exit ($tpl_main);

A return wont work because the exit is in the footer.php.  This will only return to the caller of the page, and it's the callers that continue to execute the code if the exit is not called.  I looked at the return option however there are a few levels of includes, the return just goes back to the caller, an exception will return control to whoever catches it.

Re: Integration Issue with exit ($tpl_main);

I'm open to suggestions on how to improve this for 1.3.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Integration Issue with exit ($tpl_main);

rickard, maybe a popup window for login... hehe
example
http://modelcrowd.com/forum.php
click login..or register....

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: Integration Issue with exit ($tpl_main);

Nah, that's unneeded wink And some browsers don't support it wink