Professional CodeIgniter, Thomas Myer

Chapter 8: Last-Minute Upgrades
255


There will be a way to unsubscribe people from the list, both via e - mail and on the admin
screen.


There will be a way to create a new message, reusing the WYSIWYG editor you installed for the
page manager.


Creating a Simple Controller

To start off with, all you need is a bare - bones controller with
index()
,
delete()

, and
sendemail()

functions. For now, you can leave the
sendemail()

function as spare as possible, as you can fill in the
details later:
<
?php
class Subscribers extends Controller {
function Subscribers(){
parent::Controller();
if ($this-
>
session-
>
userdata(`userid')
<
1){
redirect(`welcome/verify','refresh');
}
}
function index(){
$data[`title'] = "Manage Subscribers";
$data[`main'] = `admin_subs_home';
$data[`subscribers'] = $this-
>
MSubscribers-
>
getAllSubscribers();
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
function delete($id){
$this-
>
MSubscribers-
>
removeSubscriber($id);
$this-
>
session-
>
set_flashdata(`message','Subscriber deleted');
redirect(`admin/subscribers/index','refresh');
}
function sendemail(){
//fill in the rest later
$data[`title'] = "Send Email";
$data[`main'] = `admin_subs_mail';
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`dashboard');
}
}//end class
?
>




Creating the Subscriber Home Page View

The next step is to create the admin_subs_home view. This view is exactly like all the rest you ' ve built in
the admin section so far, except it doesn ' t allow the user to edit existing (or create new) subscribers. Also,
it offers a link to
sendemail()
.
c08.indd 255
c08.indd 255
6/10/08 5:37:31 PM
6/10/08 5:37:31 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.