CodeIgniter Forums

Full Version: How is YOUR CI set up?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]pgsjoe[/eluser]
I'm beginning development of my second site and one of the things I've been wondering, that I can't seem to find information on is how to have the site set up. So, figured I'd pose the question to all of you out there for some feedback.

Here are the problems I'm encountering.

1) I have an assets folder (containing css, js, flash, etc.), where do I put it? Views folder? Root? Also, how do I link to it?

2) Most sites generally have, what, maybe three different templates. An index and two different interior pages...usually. I feel like I would set up these templates inside of the views folder (views/templateA.php, views/templateB.php, views/templateC.php). But then, where would I store the content for each page. It doesn't need to be inside of a database, so where do I put it? Or, do I load each section of content as a completely different view? Or do I store it as XML.

3) I know I've seen 'em around before, but for thread/search purposes, is there a tried and true way that you've set up your .htaccess to remove the full codeIgniter from the URL structure?

4) Is it recommended, or advised against to set up folders inside of the views folder for different sections of the site. For instance, the one I'm working on now has the main content, then two products.

I guess just all in all, what is the best practice you've found for setting up your own site?

El Forum

[eluser]Kemik[/eluser]
[quote author="pgsjoe" date="1206918296"]1) I have an assets folder (containing css, js, flash, etc.), where do I put it? Views folder? Root? Also, how do I link to it?[/quote]

I have my assets folder in the root and use base_url() to link to it.

[quote author="pgsjoe" date="1206918296"]2) Most sites generally have, what, maybe three different templates. An index and two different interior pages...usually. I feel like I would set up these templates inside of the views folder (views/templateA.php, views/templateB.php, views/templateC.php). But then, where would I store the content for each page. It doesn't need to be inside of a database, so where do I put it? Or, do I load each section of content as a completely different view? Or do I store it as XML.[/quote]

The easiest way I can think of for different templates would be a templateone/header.php, templateone/footer.php and then the content would be the text. Otherwise look at Smarty templating system

[quote author="pgsjoe" date="1206918296"]3) I know I've seen 'em around before, but for thread/search purposes, is there a tried and true way that you've set up your .htaccess to remove the full codeIgniter from the URL structure?[/quote]

http://ellislab.com/codeigniter/user-gui.../urls.html
Quote:Removing the index.php file

By default, the index.php file will be included in your URLs:
www.your-site.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

[quote author="pgsjoe" date="1206918296"]4) Is it recommended, or advised against to set up folders inside of the views folder for different sections of the site. For instance, the one I'm working on now has the main content, then two products.[/quote]

Setup is completely up to you. Personally, I have the views folder then a folder for each controller. E.g. views/news, views/user, etc. Makes it easily to transfer code to other projects. You could use a prefix e.g. news_ or user_ if you don't like folders.

El Forum

[eluser]Jamie Rumbelow[/eluser]
In terms of assets, the whole system works from the one index.php file at the root, so you dont even need base_url()

You can organise the views folder however you like, just remember to put $this->load->view("/news/news_view"); instead of just "news_view"