views:

49

answers:

1

Ok so I've been studying Codeigniter and PHP for a week or so now and I'm ready to begin my first site. I'm wondering what are best practices for handling files that aren't Models, Views, or Controllers? Such as includes, stylesheets, javascript files (like my jQuery), etc...

From the tutorials I read, I've developed a habit of taking my Application folder and moving it up one directory to be in the same folder as my System and User Guide (which I'll probably delete User Guide before going live of course). Now with includes (headers and footers) I've noticed some developers make a subdir in the Views folder, usually called Globals, and put them there. What about javascript and css files? Do I need to put them in subfolders of the APPPATH and make constants for their location?

I'm trying to plan ahead. Thank you as always!

+5  A: 

I'm not sure if there really is a best practice for where to locate your files. I follow the practice of making a subfolder in views for the template documents (header, footer, template, etc.) and then I typically put the styling and js at the root level (I have the folders application, css, images, js, and system)

I personally think it looks a bit cleaner to do it this way.

<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen" />

IMO is a bit easier to read and maintain than

<link rel="stylesheet" href="<?php echo base_url();?>application/views/globals/css/style.css" type="text/css" media="screen" />
Johnny Tops
Save a couple characters ?>
Mitchell McKenna
Mitchell, I'm probably the last person to correct you on that, but I've seen in what little tutorials I've read that it is bad practice... I don't know why, but that is just what I've heard.
drpcken
Thank you Johnny! Exactly what I was looking for.
drpcken
One reason to avoid using short tags is if you don't have access to the php.ini file. They must be enabled in there in order for the server to properly interpret them.
Johnny Tops