hatrickpatrick Posted December 2, 2007 Share Posted December 2, 2007 I want footers to appear on all my pages, but I never realised auto_append is ignored with exit;s, which my code is full of... Is there ANY way to force the footer on every page, other than by going through every file I've made and adding it before all the exits? It'd take hours that way, the site is huge already... I troed adding it to header.inc.php as a <div>, with bottom postsion absolute, but the problem is I need it under the content, not just at the bottom of the browser window... Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 2, 2007 Share Posted December 2, 2007 You should only exit()/die() on fatal errors where you don't want to display the rest of your page. You need to design your logic differently. Rather than exit() use if/else logic to surround your code so that it only executes the portion that you want, then when any block of code is complete, you can continue with the rest of the page, including your footer. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 2, 2007 Share Posted December 2, 2007 Content placement and design shouldn't be controlled by your PHP, but by CSS. Sounds like your code flow isn't organized. Even with exits, you can still code it so the page that is displayed will show all the HTML. Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 2, 2007 Share Posted December 2, 2007 Using exit() or die() on a production site is unprofessional. We use it day in day around here in code examples, but in reality, production code should -always- display the webpage as the final act of the script. Your code should be making decisions and building up the content. If that's just simply an error message to the user, then that's fine. I'm sympathetic that your site seems rather large to try and perform surgery, but it's the best idea to do so. You should write an exit function, which accepts an error string or whatever. It should send the HTML head section, then any message, then footer stuff and closing body/html tags. Everywhere you have an exit(), insert the function. While this seems laborious, once you have the function setup, any decent text editor will have a find/replace feature in it. Use all tools available, and no undertaking will overwhelm you. PhREEEk Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 2, 2007 Share Posted December 2, 2007 Content placement and design shouldn't be controlled by your PHP, but by CSS. Sounds like your code flow isn't organized. Even with exits, you can still code it so the page that is displayed will show all the HTML. Wrong! php should control content display and output, its called CMS and its the most popular way to design any site. the trick to making your site work affectively with a php cms engine is how you handle your errors. My cms system has a bit of error checking on the content div section <?php //Display all my headers/navi pre my main dynamic content area if(SERVER_UP != 1 && empty($errors)){ //Server is down include("Serverdown.php"); } elseif(!empty($errors)){ //Some sort of error reporting } else{ include($pagesrc.".php"); } //Display rest of page } ?> The onyl section that is altered is my main content div and the rest of the template is constant Quote Link to comment Share on other sites More sharing options...
revraz Posted December 2, 2007 Share Posted December 2, 2007 And I would say that's wrong. Just because it's not your Style doesn't make it Wrong. PHP should never control actual design, layouts, color, ect. Only to provide the data to display. Wrong! php should control content display and output, its called CMS and its the most popular way to design any site. the trick to making your site work affectively with a php cms engine is how you handle your errors. My cms system has a bit of error checking on the content div section <?php //Display all my headers/navi pre my main dynamic content area if(SERVER_UP != 1 && empty($errors)){ //Server is down include("Serverdown.php"); } elseif(!empty($errors)){ //Some sort of error reporting } else{ include($pagesrc.".php"); } //Display rest of page } ?> The onyl section that is altered is my main content div and the rest of the template is constant Quote Link to comment Share on other sites More sharing options...
hatrickpatrick Posted December 2, 2007 Author Share Posted December 2, 2007 Here's the kind of code I'm using. If it's bad coding, I'll remember that in the future, but there's unfortunately no way I can go through the entire site and change it all, it's taken me 4 months just to get the site to where it is now if (!authorized($username,$password)) { echo "You are not authorized to view this page, please return to the <A HREF=index.php>board index</a>. "; exit; } Below that, all the code for the page which you have to be logged in to view... I've never seen a site coded in any other way...? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 2, 2007 Share Posted December 2, 2007 well its aparent then you haven't designed any wyswig developer programs, as most wyswigs use php to control style and placement. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 2, 2007 Share Posted December 2, 2007 for your content area just add the else counterpart to this if so if they are approved (the else to this if) display normal content. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.