Creating a Microsite Manager with CodeIgniter.pdf
(
1235 KB
)
Pobierz
512478769 UNPDF
Thomas Myer
Creating a
Manager with
CodeIgniter
®
Wiley Publishing, Inc.
Updates, source code, and Wrox technical support at
www.wrox.com
Microsite
Contents
Introducing CodeIgniter
2
What’s Model-View-Controller?
3
Why Bother with MVC?
4
Installing and Configuring CodeIgniter
5
The Root Folder
6
The system/ Folder
6
The system/application Folder
7
Tweaking the Configuration
8
Getting Started
10
The Login Area
11
Creating the Template View
12
Creating the Login Form
14
Reworking the
index()
Function
15
Creating the MAdmins Model
16
Creating the
verifyUser()
Function
17
Autoloading the MAdmins Model
17
A Small Note about Creating Your First User
18
Creating the Admin Dashboard
18
Creating the Dashboard Controller
19
Building the Admin Area
22
Setting up the Site Builder
35
Conclusion
39
About Thomas Myer
40
Wrox Blox0 Creating a Microsite Manager with CodeIgniter By Myer - ISBN0 97804704133711 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.
Creating a Microsite
Manager with CodeIgniter®
A recent trend in online marketing has been the increased use of targeted microsites to deliver
information to prospects and customers. If you’re not familiar with the term, a
microsite
is a small
web site that is focused on a very narrow range of topics or that has a single goal (like introducing
prospects to a product line or gathering leads).
Most of the time, microsites are static sites with only a handful of pages and a few forms. They
may or may not include rich media like Flash and video. Just because they’re usually small and
tightly focused doesn’t mean that they’re one-shot deals. My experience has been that once a
marketing team strikes on the idea of building a microsite, they usually iterate over the content
and structure many times, because they have that freedom.
These iterative cycles can cause the seemingly simple goal of creating a microsite (after all, you’re
only talking about a few pages, right?) to disappear and instead be replaced by a confusing process
without any centralized control or logical workflow. Anyone who has seen a team of developers,
writers, designers, and subject matter experts (SMEs) trying to hammer out messaging for a
product rollout, while at the same time debating structure and trying to maintain publishing
control, knows that even the best intentions can be made into a hash in no time.
A good approach to the problem is to build some kind of microsite management tool that would
allow a team of marketers, writers, and developers to create a microsite and then publish the files
to a web server. In this Wrox Blox, I show you how to do just that.
You’re going to build a microsite manager using CodeIgniter, a PHP Model-View-Controller
(MVC) framework. Before getting into any of the details of MVC and CodeIgniter, let’s consider
the microsite manager itself. From a requirements perspective, the microsite manager should:
❑
Allow users to log in to a secure area.
❑
Allow users to organize content into folders or categories.
Wrox Blox0 Creating a Microsite Manager with CodeIgniter By Myer - ISBN0 97804704133711 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.
Creating a Microsite Manager with CodeIgniter®
❑
Allow users to create pages.
❑
Allow users to upload files and other media.
These requirements address the
what
(or the content) in the microsite, but eventually, the microsite
needs to be published to a target location. The developers may have little or no control over the target
environment. They may or may not, for example, be able to specify a type of database or even PHP
support. In fact, they may be publishing to an ASP or ColdFusion server, or to a server that only
supports basic HTML.
For these reasons, the microsite manager you build needs a publication function that extracts
information from the microsite database tables, applies templates to it, and then publishes the material to
a designated target, all as flat HTML. Once you have all of the material in HTML (with supporting assets
and media files, of course), you’re free to place that information on any web server you choose.
Introducing CodeIgniter
CodeIgniter was created by 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. I’ve 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.
It’s this kind of prototyping power and flexibility, by the way, that will transform the way you work
with clients — but more on that later.
Unlike Ruby on Rails, CodeIgniter doesn’t require you to adhere to a strict set of coding rules. For
example, you don’t have to name your database tables a certain way and your models another. You don’t
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 don’t have to learn a complex templating language.
❑
You don’t need to work with large-scale monolithic libraries.
❑
You can run your applications in PHP 4 or PHP 5 without too much hassle.
❑
CodeIgniter applications run with exceptional performance.
I won’t get into too many more details right now. You’ll start seeing the difference once you start coding.
For now, though, it might be useful to talk a little bit about MVC, and why it’s important. Then you can
get to work.
Wrox Blox0 Creating a Microsite Manager with CodeIgniter By Myer - ISBN0 97804704133711 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.
Creating a Microsite Manager with CodeIgniter®
What’s Model-View-Controller?
Model-View-Controller is a design pattern that allows developers to separate their code cleanly into
three categories:
❑
Models
help you maintain data.
❑
Views
display data from the model and user interface elements.
❑
Controllers
handle user events that interact with models and views.
The important thing to remember is that MVC takes the user into account — it begins with them. It’s the
user who clicks a link, moves the mouse, or submits a form. It’s the controller that monitors this activity
and takes the appropriate action (such as manipulating the model and updating the view).
Because of MVC’s three-part separation, developers can create multiple views and controllers for any
given model without forcing changes in the model design. Similarly, multiple controllers can make use
of any model. This separation allows for easily maintained, portable, and organized applications.
For example, think about an MVC application that allows you to track eCommerce items in an online
store:
❑
You would have a model for product information.
❑
You would have multiple views to show single products, products in a list, products in search
results, and so on.
❑
You would have 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.
The user visits the store’s home page.
.
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 model’s data is then transmitted to the view for the home page.
4.
The view (including the data retrieved by the model) is what the user sees in the browser.
5.
The user clicks on a link to see details on a particular product.
6.
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.
7.
The cycle begins anew when the user takes another action, such as running a search or clicking
on a link.
Wrox Blox0 Creating a Microsite Manager with CodeIgniter By Myer - ISBN0 97804704133711 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.
Plik z chomika:
hooper
Inne pliki z tego folderu:
Expert One-on-One J2EE Development without EJB.pdf
(8141 KB)
Expert Access 2007 Programming.pdf
(8806 KB)
Excel 2007 VBA Programmer's Reference.pdf
(6948 KB)
Excel 2003 VBA Programmer's Reference.pdf
(18527 KB)
Dreamweaver MX-PHP Web Development.chm
(14003 KB)
Inne foldery tego chomika:
Informatyka
Zgłoś jeśli
naruszono regulamin