TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Display Framework (http://www.talkphp.com/absolute-beginners/5030-display-framework.html)

captainmerton 10-15-2009 09:17 AM

Display Framework
 
I've been building a website and have encountered a problem with the way i've designed it and looking for some advice. I have a class for managing basic html display such as headers, footers, main navigation etc and general stuff that will appear
on all pages. The problem i have is i am outputting these elements of the page by calling methods in my display class however between outputting the header stuff and the footer stuff sometimes depending on certain conditions i want to do
a page redirect i.e. if a user tries to access a page when they arent logged in i redirect to the index page. Problem is this requires a header re-direct and i've obviously already output html within the body of the document thus the header redirect
doesnt work. Obviously one solution is to not output the display elements such as main navigation etc but just build a page display object then print it at the end. Just wondered if anyone has any guidance or advice on how they've handled this?

cachepl0x 10-15-2009 09:40 AM

If I am understanding you correctly, something like this:

PHP Code:

<?php $loggedin true; if (!$loggedin) { ?>

<p>Hello World!</p>

<?php } else { header("Location: failed.php"); } ?>

Should work. Although, it may not be the best solution.

captainmerton 10-15-2009 09:56 AM

No sorry perhaps i wasnt clear enough. I meant if people design a proper enterprise website they would split off display of the page from the business logic layer and then have a data abstraction layer for accessing the database. I am talking about the display layer. I just wondered how people would usually design this, would they build the page up as the business logic layer progresses and then output that page at the end? For example somewhere along the line in the business logic layer you may decide you need a page redirect at which point you would output a header statement and enever both about displaying any html but until you have completed all your logic you arent going to know that.

ETbyrne 10-15-2009 05:57 PM

You may want to read up on the MVC design pattern:
> http://en.wikipedia.org/wiki/Model%E...0%93controller


All times are GMT. The time now is 09:20 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0