Professional CodeIgniter

(singke) #1

Chapter 3: A 10,000 - Foot View of CodeIgniter


74


Creating the Footer


The footer file (footer.php) is even simpler than the header file, as it contains some text and a link:

Copyright < ?php echo date(“Y”); >
< ?php echo anchor(“welcome/privacy”,”privacy policy”);? >

As with the header file, you can wait until the next iteration to address exact placement of HTML.

Save this file as footer.php in the /system/application/views folder.

Fixing the Side Navigation


Of all the include files, the category navigation file (navigation.php) is probably the most complicated.
This include file assumes the existence of an incoming array (named $navlist ) that contains all the
category names and IDs. This $navlist array will be created in the controller using the model
(specifically, the model function you created above that extracts all the categories from the database).

As soon as you ’ re done with this category include, you ’ ll open the controller in an editor so you can see
how all these pieces fit together:

if (count($navlist)){
echo “ < ul > ”;
foreach ($navlist as $id = > $name){
echo “ < li > ”;
echo anchor(“welcome/cat/$id”,$name);
echo “ < /li > ”;
}
echo “ < /ul > ”;
}

It will become extremely apparent to you, once you see this include in action for the first time, that it
needs to be styled. You can do that in a separate look - and - feel pass by adjusting some elements in your
default.css file.

Save this file as navigation.php in the /system/application/views folder.

Uploading Your Files


Different developers work differently, of course, but you ’ ll find as you start out that frequently
uploading files as you perform initial setup is pretty much mandatory. Once you get the process down,
however, you ’ ll find that you only need to upload a few times during initial setup. For example, many
experienced CodeIgniter developers don ’ t even bother to upload their initial CodeIgniter base until
they ’ ve worked with configuration files and then set up rudimentary models and controllers.
Free download pdf