Professional CodeIgniter, Thomas Myer
Chapter 8: Last-Minute Upgrades
249
Updating the Welcome Controller
Now that you ' ve built the administrative tools to manage pages, tie this into the Welcome controller so
that you can display pertinent information on select pages -- such as the About Us page, the Privacy
page, and the Contact page.
Open the Welcome controller in a text editor, and scroll down to the end, where you should see three
stub functions for
about_us()
,
contact()
, and
privacy()
. You ' re going to delete those three and
replace them with a single function called
pages()
. Why? Because it makes no sense to give Claudia
unlimited capability to create new pages, but no way to add those pages except through hard - coded
controller functions.
controller functions.
Here ' s what the
pages()
function will look like when you ' re done:
function pages($path){
$page = $this-
>
MPages-
>
getPagePath($path);
$data[`main'] = `page';
$data[`title'] = $page[`name'];
$data[`page'] = $page;
$data[`navlist'] = $this-
>
MCats-
>
getCategoriesNav();
$this-
>
load-
>
vars($data);
$this-
>
load-
>
view(`template');
}
Figure 8 - 4
c08.indd 249
c08.indd 249
6/10/08 5:37:29 PM
6/10/08 5:37:29 PM