PHP
  Home arrow PHP arrow Page 4 - Building a Content Management System 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

Building a Content Management System with Code Igniter
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2008-10-08


    Table of Contents:
  • Building a Content Management System with Code Igniter
  • Creating sample MySQL tables and defining a model class
  • Building a controller class
  • Completing the CMS with view files

  • 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


    Building a Content Management System with Code Igniter - Completing the CMS with view files
    ( Page 4 of 4 )

    To get this movie-related content management system completed, it’s necessary to create all of the view files that are used for the previous “Movies” controller class to display the list of available movies and their corresponding comments, as well as the HTML form that permits the insertion of these comments into the corresponding MySQL table.

    That being said, here’s the definition of the first view file, called “movie_view.php.” It is utilized by the controller to display the list of movies available for receiving comments. Have a look at it, please:


    <html>

    <head>

    <title><?php echo $title;?></title>

    </head>

    <body>

    <h1><?php echo $title;?></h1>

    <?php foreach($movies as $movie):?>

    <h2><?php echo $movie['name'];?></h2>

    <p><?php echo $movie['description'];?></p>

    <p><?php echo anchor('movie/comments/'.$movie['id'],'View Comments');?></p>

    <hr />

    <?php endforeach;?>

    </body>

    </html>


    Definitely, the above view file is quite simple to grasp. As you can see, this file will display all of the movies stored in the database. It includes a link that will take users to the comments web page, so they can submit a new comment for each particular movie.

    Besides, you may want to look at the following screen help, which shows precisely how movies are displayed on screen:



    That image was pretty illustrative, right? Now it’s time to include the view file that renders the comments web page, which not surprisingly is called “moviecomment_view.php.” Here it is:


    <html>

    <head>

    <title><?php echo $title;?></title>

    </head>

    <body>

    <h1><?php echo $title;?></h1>

    <?php foreach($comments as $comment):?>

    <p><?php echo $comment['author'];?></p>

    <p><?php echo $comment['text'];?></p>

    <p><?php echo anchor('movie','Back to movies');?></p>

    <hr />

    <?php endforeach;?>

    <?php echo form_open('movie/insert_comment');?>

    <?php echo form_hidden('movie_id',$this->uri->segment(3));?>

    <p>Enter your comments below:</p>

    <p><textarea name="text" rows="10"></textarea></p>

    <p>Author:</p>

    <p><input type="text" name="author" /></p>

    <p><input type="submit" value="Submit Comment" /></p>

    </form>

    </body>

    </html>


    As you can see, the above view file performs a couple of crucial tasks, such as displaying all the comments that have been submitted for a specific movie, and providing a basic HTML form, which lets users add new entries.

    Of course, you’ll understand much more clearly how this view works, if you look at the following screen capture:



    See how easy it is to provide users with an interface that lets them enter comments on a specific movie? I guess you do! Naturally, these two view files should be saved to the Code Igniter /system/application/views/ folders, so that they can be loaded at runtime by the previous controller class.

    Okay, at this point I have finished building this simple content management system with Code Igniter. If you want to test it, you should type the following URL in your browser’s address field:


    http://localhost/codeigniter/index.php/movies/


    That’s all. If all of the source files created earlier were saved to the correct locations in the web server, then the application should work flawlessly!

    Finally, feel free to introduce your own modifications to the files, so you can extend your Code Igniter skills to developing database-driven applications.

    Final thoughts

    Sad but true, we’ve come to the end of this series. The journey has been long, but hopefully instructive too, since you learned how to use Code Igniter to develop several useful web applications very quickly.

    So, if you’re looking for a PHP framework that requires minimal setup and an easy learning curve, then Code Igniter might be the piece of software that you really need.

    See you in the next PHP development tutorial!



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

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - 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





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