PHP
  Home arrow PHP arrow Moving Presentation Logic Out of Views with Code Igniter
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Moving Presentation Logic Out of Views with Code Igniter
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2009-04-16


    Table of Contents:
  • Moving Presentation Logic Out of Views with Code Igniter
  • Review: returning values with a previous method
  • Moving presentation logic out of views
  • The modified source code of the sample PHP program

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Moving Presentation Logic Out of Views with Code Igniter
    ( Page 1 of 4 )

    Manipulating views with CodeIgniter is a straightforward process. In a typical situation, there’s a model that fetches some rows from one or more database tables, and a view file that receives this data through a controller class, which is finally displayed on screen, generally in the form of an HTML page. However, CodeIgniter gives PHP programmers enough freedom to handle views in several useful ways, which can speed up the development of web applications. Therefore, if you’re taking your first steps with CI and wish to learn some handy approaches that will help you work with views in a truly painless fashion, then start reading this tutorial now!

    Introduction

    At this point, after having introduced you to the subject of this series of articles, it’s time to recall the topics we discussed in the last tutorial, in case you still haven’t had the chance to read it. In summary, in that article I proceed to build a simple MySQL-driven application whose main task consisted of fetching some database rows and embedding this data into a basic view file.

    Apart from playing a bit with the schema dictated by the Model-View-Controller pattern, this particular example showed in a nutshell how to return strings from the “$this->load->view()” method to create different parts of a web page, such as the typical header and footer sections, and a main area as well.

    In addition, you’ll possibly recall that the view that displayed the database records implemented a simple presentation logic, reduced to looping over the records in question and nothing else. It’s also possible to make this view even “dumber” by moving this looping structure out of it, in this way achieving a greater level of separation between the application’s logic and its presentation layer.

    Therefore, in this fifth part of the series, I’ll be rebuilding the web application that you learned in the last article, modifying the view file responsible for displaying database rows on the web page.

    Do all these things sound interesting enough for you? Then let’s get started right now!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek