Professional Documents
Culture Documents
Creating
a Blogging
Tool with
Codeigniter
Wiley Publishing, Inc.
Updates, source code, and Wrox technical support at www.wrox.com
Contents
Introducing CodeIgniter
Whats Model-View-Controller?
Why Bother with MVC?
Getting Started
The Public-Facing Site
Creating the Template View
Creating the Home Page View
Creating the Category View
Creating the Blog Details View
Creating the Login Form
Verifying Logins
Creating the MAdmins Model
Creating the verifyUser() Function
A Small Note about Creating Your First User
Summary
About Thomas Myer
2
2
4
5
6
7
7
8
10
12
14
16
19
20
22
23
24
24
25
25
26
28
34
38
39
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
A way to display a single post with comments (and a way for others to comment
on a post)
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Now that you know what to build, its time to download CodeIgniter and get the general overview.
Introducing CodeIgniter
CodeIgniter was created by the good folks over at EllisLab, Inc. It is a Model-View-Controller (MVC)
framework with a very small footprint. In form and function, it is very similar to other MVC
frameworks, like Ruby on Rails. Like Ruby on Rails, it requires very little configuration to get started.
Ive been able to create prototype applications within hours of talking to a client, and then refined the
prototypes over the course of a few days.
Its this kind of prototyping power and flexibility, by the way, that will transform the way you work
with clients. It allows you to be responsive and collaborative in ways that youre probably not used to.
Unlike Ruby on Rails, CodeIgniter doesnt require you to adhere to a strict set of coding rules.
For example, you dont have to name your database tables a certain way, and your models another.
Youdont even have to have strictly formatted table fields which makes CodeIgniter an excellent
platform for recoding legacy applications.
Below are a few more great things about CodeIgniter:
There is a growing toolbox of helpers and libraries that help you do your job quickly.
You can run your applications in PHP 4 or PHP 5 without too much hassle.
This section doesnt get into too many more details right now. Youll start seeing the difference once you
start coding. For now, it might be useful to talk a little bit about MVC and why its important. Then
youll get to work.
Whats Model-View-Controller?
Model-View-Controller is a design pattern that allows developers to separate their code cleanly into
three categories:
Views display data from the model and user interface elements.
Controllers handle user events that interact with models and views.
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Multiple views to show single products, products in a list, products in search results, and so on
At least one controller that would organize those views into destinations, such as index()
(for home page), product_detail(), and search_results()
Drilling down further, an MVC eCommerce application might involve the following flow of events:
1.
2.
3.
4.
5.
6.
The models data are then transmitted to the view for the home page.
7.
The cycle begins anew when the user takes another action, such as running a search or clicking a
link.
This simple event requires a controller action for the home page, which makes a quick call to the
model to retrieve the 10 most popular products based on recent sales.
The view (including the data retrieved by the model) is what the user sees in the browser.
The user clicks a link to see details on a particular product.
The underlying controller captures this user input (clicking the link), uses the model to retrieve
the product in question from the database, and then loads the appropriate view.
Another way of thinking about this breakdown of roles is to map it out as follows (see Figure 1):
Output = View
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
interacts with
view
controller
manipulates
updates
model
Figure 1: The Model-View-Controller framework in
action.
This three-part analogy is a much simpler way of looking at things. Some might argue that the approach
is much too simple. After all, its possible, some might argue, to create an MVC application without a
model, or to gang-press view code into the controller. Its not a good idea, but it can be done. For right
now, the simple analogy will hold.
Change the number of products that get retrieved (or even the order in which the products are
displayed), she updates the model.
Change the way the home page looks, she updates the view.
Add a new page to the application, she first adds a method to the controller and then builds out
any supporting views (to display content in the browser) and models (to gather data from a
database).
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Figure 2: CodeIgniter.com.
Once youve downloaded the Zip archive, double-click it to open it, and place the contents of the archive
in your favorite work area. Once youve done that, take a moment to tour CodeIgniter.
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
The system/Folder
The system/folder is where all the action happens. This folder contains all the CodeIgniter code of
consequence, organized into various folders:
Folder
Description
application
Contains the application youre building, which includes your Models, Views,
Controllers, and other code (like helpers and class extensions). In other words,
this folder is where youll do 99% of your work.
cache
codeigniter
Where CodeIgniters core classes live. You have almost no reason to go in here.
All of your work occurs in the application folder.
database
Contains core database drivers and other database utilities. Again, theres no
good reason for you to be in this folder.
fonts
helpers
Contains standard CodeIgniter helpers (such as Date, Cookie, and URL helpers).
Youll make frequent use of helpers in your CodeIgniter career, and can even
extend helpers thanks to improvements introduced in CodeIgniter version 1.6.
language
libraries
Contains standard CodeIgniter libraries (to help you with e-mail, calendars, file
uploads, and more). You can create your own libraries or extend (and even
replace) standard libraries, but those are saved in the application/libraries
directory to keep them separate from the standard CodeIgniter libraries.
logs
The folder to which CodeIgniter writes error and other logs. This needs to be
writable if you enable logging.
plugins
Contains plug-ins. Plug-ins and helpers are very similar, in that they both allow
developers to address an issue or create content (like forms, links, etc.) quickly.
The main difference between them is that plug-ins usually consist of one
function, while helpers often have many functions bundled inside them.
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Folder
Description
config
Contains several important files that control your configuration options. There
are files that manage your database setup and other variables that CodeIgniter
needs to know (such as the base URL, which libraries and helpers to autoload,
etc.). The four most important files in this folder are config.php, database.php,
autoload.php, and routes.php.
controllers
errors
Comes with standard CodeIgniter error templates for 404 pages, PHP errors,
and others. You are free to modify these templates to make them fit the look and
feel of your application.
hooks
Contains any hooks you create for your application. Hooks are the best way to
extend the CodeIgniter core safely.
libraries
models
views
In other words, the most important folders in the /system/application folder are controllers/, models/,
and views/. Youll spend practically all your development time working with the Models, Views, and
Controllers that you build.
The other very important folder is config/, which contains various important configuration files. Youll
want to open them in an editor for tweaking before starting any project. Most of the time, when you start
a new CodeIgniter project, youll start with the config/ folder.
config.php
The config.php file contains a series of configuration options (all of them stored in a PHP array called,
appropriately enough, $config) that CodeIgniter uses to keep track of your applications information
and settings.
The first configuration option you need to set inside of config.php is the base URL of your application.
You do that by setting the absolute URL (including the http:// part) for $config[base_url],
like so:
$config[base_url] = http://www.example.com/test/;
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
For more details on each of these configuration options, simply read the comments embedded in
/system/application/config/config.php. As you progress through the installation, there will be some
opportunities to talk about configuration options, and this Wrox Blox will bring up some points if its
appropriate.
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
=
=
=
=
=
=
=
=
=
=
=
=
your-host-name;
your-db_username;
your-db_password;
your-db_name;
mysql;
;
TRUE;
TRUE;
FALSE;
;
utf8;
utf8_general_ci;
Other Files
There are other important files in the config/ directory, namely, routes.php and autoload.php. You dont
need to know anything about routes.php right now, but you will want to autoload a few helpers and
libraries before you get started.
Youll want to autoload the Database and Session libraries, so that you dont have to call those libraries
every time you want to query the database or work with CodeIgniter sessions. On the helpers side,
youll be using the URL, Form, and Text helpers constantly, so they might as well be loaded.
$autoload[libraries] = array(database,session);
$autoload[helper] = array(url,form,text,typography);
There is one more task to be done before leaving the autoload.php file: autoloading models. In the days
prior to CodeIgniter 1.6, you had to load a model manually every time you used it in your controller.
Not anymore! You can autoload them and use the model functions at any point.
Although you dont have any models built yet, at various points in this application, youll be building
models and then immediately autoloading them in the autoload.php file.
10
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
A way to display a single post with comments (and a way for others to comment on a post)
An administrative area that allows for management of users, posts, and categories
You will translate these requirements into CodeIgniter terms. Eighty percent of this application will be
some kind of administrative dashboard that will be password-protected. The other 20 percent is a series
of public-facing display pages that contain blog posts. You will need to build two sets of controllers for
CodeIgniter:
The first set, which you will call Blog, will contain a handful of functions.
The second group contains multiple controllers, one for the main dashboard and the others for
posts, categories, and users. This set of controllers will be organized under a folder called admin/
in your controllers directory. There will be more about this later, but for now, just know that you
can organize your files into convenient folders.
You will need one model for each database table. Because you will need to track users, posts, categories,
and comments, you need a model for each of those. For the time being, you also need database tables for
each of these models. You will build those database tables as you go.
Here are the database tables you need. First, the categories table:
CREATE TABLE `categories` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) NOT NULL default ,
`shortdesc` varchar(255) NOT NULL default ,
`longdesc` text NOT NULL,
`status` enum(active,inactive) NOT NULL default active,
`sortorder` int(3) NOT NULL default 0,
`parentid` int(11) NOT NULL default 0,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
11
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
You will also have about a dozen views. Most of them will be for our administrative views, but a few
will be used on the public-facing side of the web application.
Now that you have all of that roughed in, lets create the first controller next.
1.
<?php
class Blog extends Controller {
function Blog(){
parent::Controller();
session_start();
}
}//end controller class
?>
2.
Note that when you create a controller, you have to follow a few basic rules. The name of the class
is always capitalized, and it must match the name of the file. Therefore, you have the class Blog
in the blog.php file. Furthermore, you need a constructor of the same name inside your class. The
example above is PHP 4. If you were working in PHP 5, your constructor would look as follows:
12
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Notice that in both examples, youre initializing PHP Sessions with session_start(). Youll see why youre
using PHP Sessions as you continue working with the application. CodeIgniter comes with its own Sessions,
but those are cookie-based and therefore accessible to the client. They can be encrypted, of course, but this
fact doesnt mean that you should completely trust them. Later on, when you build the part of the application
that allows users to log in to the administrative panels, you want a more secure system of determining
successful login than a client-side cookie. PHP Sessions offers that, as the data are stored server-side.
3.
Once you have your constructor in place, all you have to do is add some functions. You will
need functions for every single destination in the controller. In this case, you will need a
destination for the home page, traditionally handled by an index() function.
Your index() function is very basic it just needs to display some navigation items and a certain
number of blog posts. This content isnt placed in the controller function, but is instead handled in a
view, which youll get to below. As you can see, we are using some models to call up data for the view to
display:
function index(){
$data[posts] = array(); //we will replace soon!
$data[cats] = array(); //we will replace soon!
$data[title] = Welcome;
$data[main] = public_home;
$this->load->vars($data);
$this->load->view(template);
}
Notice that you are saving information in a $data array (like the variables: title and main), and then
loading that array with $this->load->vars($data). All youre doing here is making the $data array
available to a view called Template.
13
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
14
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
You can nest your views using the $this->load->view() command, as long as you feed it the name of
a view in your application. Sometimes you manually set the name of a view (like you did with nav), and
at other times, you can dynamically load a view with a PHP variable. Notice that youre doing just that
by feeding in the variable $main in the second instance.
15
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
As you can see, all you need is for $data[cats] in your Blog controller to contain a simple array. The
keys of this array would be category IDs, and the values would be category names. Keep that in mind
while you work on the public_home template view.
The public_home view is very simple. Its basically expecting an array from the Blog controller. If it finds
one, it iterates over the array and prints out the title of the blog posting and the first 200 words.
<?php
if (count($posts)){
foreach ($posts as $key => $list){
echo <h2>.$list[title].</h2>\n;
echo auto_typography(word_limiter($list[body], 200));
echo anchor(blog/post/.$list[id],read more >>);
}
echo <br/><br/>;
}
?>
16
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
1.
2.
3.
You should call the categories model MCats, and the posts model MPosts. Other developers have their
own naming conventions, preferring to use model_x or x_model for their model names, but the simple
Mx model is short and tells you right away that youre dealing with a model. As you work with this
application, youll be adding plenty of functions to each model, but for now, all you need is a few
functions to get you going.
In the MCats model, you need an easy way to pull out a simple array of categories so you can build a
navigation element on the public-facing web site. Before you build that, you need to create a model:
<?php
class MCats extends Model{
function MCats(){
parent::Model();
}
}//end class
?>
So far, so good, right? Just like with controllers, your model name must be identical to its filename, and
you have to instantiate the model as you would any other PHP class.
Before you do anything, remember to add your models to the autoload.php file (might as well add the
one for users, posts, and comments while youre at it!):
$autoload[model] = array(MCats,MPosts,MAdmins,MComments);
Now that theyre autoloaded, youre free to use functions from them without having to call them
beforehand.
17
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Now all you have to do is go back to our Blog controller and insert this function into the right space:
function index(){
$data[posts] = array();
$data[cats] = $this->MCats->getTopCategories();
$data[title] = Welcome;
$data[main] = public_home;
$this->load->vars($data);
$this->load->view(template);
}
Next, you need a simple function that will retrieve a certain number of posts for the home page. You
dont want to hardcode the number of posts in the model function, so youll pass in a limit. Heres what
the model function would look like:
<?php
class MPosts extends Model{
function MPosts(){
parent::Model();
}
function getLivePosts($limit){
$data = array();
$this->db->limit($limit);
$this->db->where(status, published);
$this->db->order_by(pubdate,desc);
$Q = $this->db->get(posts);
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
$data[] = $row;
}
}
$Q->free_result();
return $data;
}
}
?>
18
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Its very similar to the index() function. It assumes that were going to pass in some kind of category ID
(which we will refer to as simply $id in this context). It then uses that $id to fetch the category via a
getCategory() function, and all posts assigned to a category via a getAllPostsByCategory() function.
First, lets build the getCategory() function in the MCats model:
function getCategory($id){
$data = array();
$this->db->where(id,$id);
$this->db->limit(1);
$Q = $this->db->get(categories);
if ($Q->num_rows() > 0){
$data = $Q->row_array();
}
$Q->free_result();
return $data;
}
This function is very simple. It retrieves one record from the categories table that matches the ID you
pass in, returning an array.
19
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
You pass in a $catid and use it to filter which posts you return, making sure that you also only grab
those posts with a status of published. Make sure that you return an array, because in the end, youre
passing all of this information to the public_home view, which youve already used for your home page.
Youre passing in an $id variable that will map to the post ID. Youll use that here in much the same way
you used the category ID when you viewed posts by category. It looks like you need to add one more
function to the MPosts model [getPost()] and create a model called MComments.
Lets add the getPost() function to the MPosts model first:
function getPost($id){
$data = array();
$this->db->where(id,$id);
$this->db->limit(1);
$Q = $this->db->get(posts);
if ($Q->num_rows() > 0){
$data = $Q->row_array();
}
$Q->free_result();
return $data;
}
20
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Now that you have the models under control, you should create a simple view called public_post. This
view will consist of the blog posting and any comments that are associated with it, followed by a simple
form that will allow users to post their own comments.
<?php
echo auto_typography($post[body]);
?>
<h3>Comments</h3>
<?php
if (count($comments)){
21
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Whenever you get the chance, you should let CodeIgniter help you as much as possible (as youre doing
in this Wrox Blox). Youre using auto_typography() to help lay out the content for the posting and
comments. Youre also using helpers like form_open(), form_label(), form_input(),
form_hidden(), and form_submit() to help you build a very fast and simple comment form.
Notice the form_open() function points to blog/addcomment. This means that you need a new function
in your Blog controller, one called addcomment(). This function has a very simple job: insert the comment
from the form into the database and then redirect the user back to the blog posting they were on.
The way to do this is very simple: call the model function you want to do the job. In this case, you want
the addComment() function of the MComments model.
function addcomment(){
if ($this->input->post(body)){
$this->MComments->addComment();
}
redirect(blog/post/.$this->input->post(post_id), refresh);
}
22
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
form_open(blog/verify);
form_label(username,u) .<br/>;
form_input($udata) . </p>;
form_label(password,p) .<br/>;
form_password($pdata) . </p>;
form_submit(submit,login);
form_close();
To open a form, use form_open() and pass in the URI to which the form posts. This is equivalent to the
action attribute of a form. In your case, you want this simple form to post to blog/verify, which means
you will need to add a new function.
Notice that you then use form_input() and form_password() to create a text field followed by a
password field. Also notice that each of these has a short array containing necessary values (like the field
name, DOM ID, and size) that gets passed to that field. Also notice the use of form_label(), a handy
shortcut for your labels (which are a good accessibility thing to have on your forms).
Finally, you create a submit button with form_submit() and close the form with form_close().
Although you may now be wondering why you would go to all this trouble, after only a short while,
youll wonder how you got along without this helper.
Verifying Logins
At this point, you have a Login form that posts back to blog/verify, which means that you need to add a
verify() function. If there are POST data, the function needs to take the values from the form, encrypt
the password using some simple method, and then check to see whether there are any users in the
database that match the values from the form. The encrypting and checking can be done inside
the model to keep things simple.
Heres a complete version of the verify() function:
function verify(){
$this->load->library(encrypt);
if ($this->input->post(username)){
$u = $this->input->post(username);
$pw = $this->input->post(password);
$row = $this->MAdmins->verifyUser($u,$pw);
23
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
The first thing you do now is load the encrypt library. This library is only used during login, so there is
no need to autoload it. Once loaded, it will be used by the model youre going to create to communicate
with the database table that will store administrative users.
The second thing you do is use $this->input->post() to check to see whether there is a value in a
field called username. If there is a value, then you grab the username and password values and hand this
information off to the MAdmins model (which you havent built yet) and specifically, the verifyUser()
function of that model.
What you need to receive is an array of data. If you do get back an array, you can populate a PHP session
variable called userid and then redirect the user to the admin/dashboard controller (youll be building
that shortly, as well). If you dont get back a data array, you simply redirect the user to the Login form so
they can try to log in again.
So heres what you need to do before youre done with the login area:
1.
2.
24
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
If you recall, the controller verify() function that is calling verifyUser() is expecting a row
containing an ID, so that it can set a PHP Session value. It will accept an empty array, but that causes
the controller to redirect back to the login page.
Dashboard This is the home area for your administrative area, and includes all publication
functions.
25
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
dashboard.
logout() Allows users to log out.
Heres what the top of our Dashboard controller looks like (remember, it is stored in the /system/
application/controllers/admin folder):
<?php
class Dashboard extends Controller {
function Dashboard(){
parent::Controller();
session_start();
if ($_SESSION[userid] < 1){
redirect(blog/login,refresh);
}
}
}//end class
The controller starts typically enough, with the right naming conventions, and includes a very short
check to make sure that the Session variable called userid has been set. If it has a value less than 1, then
the user is redirected to the Welcome controller, and specifically to the Login form. Youre going to add
this little bit of code to every single controller in the admin/ folder to keep out any unauthorized users.
Once that little bit of business is done, you can build the index() function:
function index(){
$data[title] = Dashboard Home;
$data[main] = admin_home;
$this->load->vars($data);
$this->load->view(dashboard);
}
Youre doing essentially the same thing you did before, on the Login screen, except youre loading a
Dashboard view instead of the Template view.
26
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
This Dashboard template, in turn, loads an admin_header, an admin_footer, and whatever value has
been loaded into $data[main] from the controller (in this case, admin_home).
Here is the admin_header view:
<div id=globalnav>
<ul>
<li><?php echo anchor(admin/dashboard/index,home);?></li>
<li><?php echo anchor(admin/categories/,categories);?></li>
<li><?php echo anchor(admin/posts/, posts);?></li>
<li><?php echo anchor(admin/admins/, users);?></li>
<li><?php echo anchor(admin/dashboard/logout/, logout);?></li>
</ul>
</div>
Essentially, this is the main navigation tool that goes across the top of the admin dashboard. Once youve
built all the necessary controllers and views, all of this will start working like a charm. For now, take a
look at the use of the anchor() shortcut function. This function is part of the URL helper. It builds links
for you, and accepts two arguments, the link destination and the link text.
27
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
This one line of HTML and PHP will put a copyright notice on the bottom of each page.
Finally, heres the admin_home view:
<ul>
<li><b><?php
.</b></li>
<li><b><?php
<li><b><?php
<li><b><?php
</ul>
It is basically the same list of links seen in the main navigation. You could, if you wanted, add more
information in there, like a listing of the last five postings made on the blog.
Before you move on to the other controllers, finish the Dashboard controller. You still need the logout()
and build_site() functions. Heres the logout() function, which basically unsets the PHP Session
variable userID and redirects the user to the login screen:
function logout(){
unset($_SESSION[userid]);
redirect(welcome/index,refresh);
}
Now that youve got the Dashboard figured out, create the other controllers you need, starting with the
Admin area first.
An index() function allows users to see data within the database table at a glance.
28
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
The index() function loads the admin_admins_home view and requires the creation of a model
function called getAllUsers(). As you can guess, this function retrieves all users from the database:
function index(){
$data[title] = Manage Users;
$data[main] = admin_admins_home;
$data[admins] = $this->MAdmins->getAllUsers();
$data[tinymce] = ;
$this->load->vars($data);
$this->load->view(dashboard);
}
The create() function is very simple. You want to create a dual-purpose function here, similar to your
login screen. If there are POST data, run a function called addUser() and redirect the user to the
index() function. If not, show the admin_admins_create view:
function create(){
$this->load->library(encrypt);
if ($this->input->post(username)){
$this->MAdmins->addUser();
redirect(admin/admins/index,refresh);
}else{
$data[title] = Create User;
$data[main] = admin_admins_create;
$data[tinymce] = ;
$this->load->vars($data);
$this->load->view(dashboard);
}
}
Similarly, the edit() function also looks for POST data. If it finds any, it runs the updateUser()
function and redirects the user to the index() function. If it doesnt, it loads the admin_admins_edit
view. Notice that it also runs the getUser() model function, which youll use to populate the form
fields.
29
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Finally, theres the delete() function, which will pass in a user ID via a link and run the deleteUser()
model function:
function delete($id){
$this->MAdmins->deleteUser($id);
redirect(admin/admins/index,refresh);
}
}
?>
The getAllUsers() function is similarly easy to understand. It returns all rows in the designated table
(in this case, ms_admins):
function getAllUsers(){
$data = array();
$Q = $this->db->get(users);
30
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
The addUser() function accepts an incoming array of POST data and then uses $this->db->insert()
to place those data in the right table:
function addUser(){
$data = array(username => $this->input->post(username),
email => $this->input->post(email),
status => $this->input->post(status),
password => md5($this->input->post(password))
);
$this->db->insert(users,$data);
}
The updateUser() function also accepts an incoming array of POST data and then updates the table
using $this->db->update(). Notice that tucked away inside the POST data is some kind of ID field.
You should make sure to put that inside the view to keep things working correctly.
function updateUser(){
$data = array(username => $this->input->post(username),
email => $ this->input->post(email),
status => $ this->input->post(status),
password => md5($this->input->post(password))
);
$this->db->where(id,$ this->input->post(id));
$this->db->update(users,$data);
}
The deleteUser() function accepts an ID and then sets the status of that record to inactive. Im not a
big believer in actually deleting items from the database, so thats why Ive opted for a deactivation instead
of deletion. Because of that, youre using $this->db->update() instead of $this->db->delete():
function deleteUser($id){
$data = array(status => inactive);
$this->db->where(id, $id);
$this->db->update(users, $data);
}
31
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Notice that you can easily create a new user with the link along the top, and edit or delete any existing
record once it loads up in the table. When youre done, your user area will look a little like the illustration in Figure 4.
32
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Notice that youve introduced another element here called form_dropdown(), a handy shortcut that
allows the easy creation of dropdowns. All you have to do is create an array of options and then pass it
in to form_dropdown() to create your values. This array can be set manually, or it can be generated
from a query.
For all intents and purposes, the admin_admins_edit view contains the same exact form, except youre
loading values into each field. Remember that the controller function edit() has run the getUser()
model function to pull in the corresponding record for a given user ID. Those data were stored in
$data[admin], so you can access them via $admin.
<h1><?php echo $title;?></h1>
<?php
echo form_open(admin/admins/create);
echo form_label(username,u);
$data = array(name=>username,id=>uname,size=>25,
value=>$admin[username]);
echo form_input($data) .</p>;
echo form_label(email,email);
$data = array(name=>email,id=>email,size=>50,
value=>$admin[email]);
echo form_input($data) .</p>;
echo form_label(password,pw);
$data = array(name=>password,id=>pw,size=>25,
value=>);
echo form_password($data) .</p>;
echo form_label(status,status);
$options = array(active => active, inactive => inactive);
echo form_dropdown(status,$options,$admin[status]) .</p>;
echo form_submit(submit,update admin);
echo form_close();
?>
33
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Categories
First, lets talk about categories. Categories, for the purposes of this application, are defined as generic
containers (like folders) that can hold pages. When you create the site building function for the
Dashboard controller, youll organize all the output into their proper categories, using the category
names as folder names.
The categories area has a very simple controller. Looking at it, you will notice that almost the same thing
is going on in this controller as went on in the Admins controller. The only difference is, youre calling
different views.
Heres the Categories controller:
<?php
class Categories extends Controller {
function Categories(){
parent::Controller();
session_start();
if ($_SESSION[userid] < 1){
redirect(welcome/index,refresh);
}
}
function index(){
$data[title] = Manage Categories;
$data[main] = admin_cat_home;
$data[categories] = $this->MCats->getAllCategories();
$this->load->vars($data);
$this->load->view(dashboard);
}
function create(){
if ($this->input->post(name)){
$this->MCats->addCategory();
redirect(admin/categories/index,refresh);
}else{
$data[title] = Create Category;
$data[main] = admin_cat_create;
$data[categories] = $this->MCats->getTopCategories();
$this->load->vars($data);
$this->load->view(dashboard);
}
}
function edit($id=0){
34
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
As you can see, the same patterns emerge. The controller calls model functions, sets variables, and loads
those variables into a particular view. In your case, youre building administrative panels, so the view
wont vary much. Theyll either be a listing of available records or a form that allows you to create new
records or edit existing records.
Youve already created a few functions in the MCats model as you worked on the public side of the site;
now its time to add a few more, so you can continue working on the admin side:
<?php
class MCats extends Model{
function MCats(){
parent::Model();
}
function getCategory($id){
$data = array();
$options = array(id => $id);
$Q = $this->db->getwhere(categories,$options,1);
if ($Q->num_rows() > 0){
$data = $Q->row_array();
}
$Q->free_result();
return $data;
}
function getAllCategories(){
$data = array();
$Q = $this->db->get(categories);
if ($Q->num_rows() > 0){
foreach ($Q->result_array() as $row){
35
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
36
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
function create(){
if ($this->input->post(title)){
$this->MPosts->addPost();
redirect(admin/posts/index,refresh);
}else{
$data[title] = Create Post;
$data[main] = admin_posts_create;
$data[cats] = $this->MCats->getCategoriesDropDown();
$this->load->vars($data);
$this->load->view(dashboard);
}
}
function edit($id=0){
if ($this->input->post(title)){
$this->MPosts->updatePost();
$this->session->set_flashdata(message,Post updated);
redirect(admin/posts/index,refresh);
}else{
//$id = $this->uri->segment(4);
$data[title] = Edit Post;
$data[main] = admin_posts_edit;
37
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
}//end class
?>
Summar y
Now that you have an administrative area up and running, create a few categories and start publishing
posts. What youll see is a growing list of categories in your navigation and a growing list of Blog posts,
as illustrated in Figure 5. It isnt the prettiest thing in the world, but youve met your end of the deal: a
working blog application prototype in a matter of hours!
38
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
39
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
www.wiley.com
Copyright 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
ISBN: 978-0-470-41338-8
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal
Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or
online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is
sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Neither
the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or the
publisher endorses the information the organization or Website may provide or recommendations it may make. Further,
readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this
work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. CodeIgniter is a registered trademark of EllisLab, Inc. All
other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or
vendor mentioned in this Wrox Blox.
This PDF should be viewed with Acrobat Reader 6.0 and later, Acrobat Professional 6.0 and later, or Adobe Digital Editions.
Usage Rights for Wiley Wrox Blox. Any Wiley Wrox Blox you purchase from this site will come with certain restrictions
that allow Wiley to protect the copyrights of its products. After you purchase and download this title, you:
Copy Editor
Cate Caffrey
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
Wrox Blox0 Creating a Blogging Tool with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.
Professional CodeIgniter
By THOMAS MYER
978-0-470-28245-8 Paper 304 pages
Wrox Blox0 Creating
a Blogging
with CodeIgniter By Myer - ISBN0 97804704133881 Prepared for CHRISTOPHER RINGWALD/ email0
Visit
us at Tool
www.wrox.com
callananclare@aol.com Order number0 40397143 Copyright 2009/ Wiley Publishing Inc. This PDF is exclusively for your use in accordance
with the WroxBlox Terms of Service. No part of it may be reproduced or transmitted in any form by any means without prior written
permission from the publisher. Redistribution or other use that violates the Wrox Blox Terms of Service or otherwise violates the U.S.
copyright laws is strictly prohibited.