TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-15-2009, 09:17 AM   #1 (permalink)
The Acquainted
 
captainmerton's Avatar
 
Join Date: May 2009
Posts: 178
Thanks: 9
captainmerton is on a distinguished road
Default 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?
captainmerton is offline  
Reply With Quote
Old 10-15-2009, 09:40 AM   #2 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default

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.
cachepl0x is offline  
Reply With Quote
Old 10-15-2009, 09:56 AM   #3 (permalink)
The Acquainted
 
captainmerton's Avatar
 
Join Date: May 2009
Posts: 178
Thanks: 9
captainmerton is on a distinguished road
Default

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.
captainmerton is offline  
Reply With Quote
Old 10-15-2009, 05:57 PM   #4 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

You may want to read up on the MVC design pattern:
> http://en.wikipedia.org/wiki/Model%E...0%93controller
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Framework: Do's and Don'ts Jim Advanced PHP Programming 7 04-14-2009 03:00 PM
Critique the framework I use Enfernikus Advanced PHP Programming 4 04-02-2009 12:18 AM
Zoop Framework 1.5 released bobthecow Libraries & Extensions 3 11-02-2008 06:54 PM
Framework Rendair Javascript, AJAX, E4X 1 03-09-2008 10:28 PM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM


All times are GMT. The time now is 06:43 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design