Where is it acceptable to put css folders and image file folders? I was thinking inside the view folder? However the controller always reroutes the path to the base url so I
This is how I handle the public assets. Here I use Phalcon PHP's Bootstrap method.
|-.htaccess*
|-application/
|-public/
|-.htaccess**
|-index.php***
|-css/
|-js/
|-img/
|-font/
|-upload/
|-system
.htaccess*
All requests to the project will be rewritten to the public/ directory making it the document root. This step ensures that the internal project folders remain hidden from public viewing and thus eliminates security threats of this kind. - Phalconphp Doc
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
.htaccess**
Rules will check if the requested file exists and, if it does, it doesn’t have to be rewritten by the web server module. - Phalconphp Doc
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
index.php***
Modify the application
path and the system
path as,
$system_path = '../system';
$application_folder = '../application';
Now you use the public
folder as base_url()."public/[YOUR ASSET FOLDER]"
Hope this helps :)
Hi our sturucture is like Application, system, user_guide
create a folder name assets just near all the folders and then inside this assets folder create css and javascript and images folder put all your css js insiide the folders
now go to header.php and call the css just like this.
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/touchTouch.css">
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/camera.css">
The link_tag()
helper is clearly the way to do this. Put your css where it usually belongs, in site_root/css/ and then use the helper:
From The CodeIgniter docs...
echo link_tag('css/mystyles.css');
Output
<link href="http://example.com/css/mystyles.css" rel="stylesheet" type="text/css" />
I usually put all my files like that into an "assets" folder in the application root, and then I make sure to use an Asset_Helper to point to those files for me. This is what CodeIgniter suggests.
Regardless of where you put the CSS file you can simply use the CodeIgniter "html" helper called link_tag(). You would apply this helper something like this:
echo link_tag('folder/subfolder/stylesheet.css');
It is up to you to locate the CSS file in the most appropriate place (in your opinion). You would have to either autoload the "html" helper or separately load it in to use it.
People keep suggesting the usage of base_url() to achieve this but it is actually not really the "CodeIgniter" way to do it (I think this question has a few duplicates). That will work but one of the reasons for using a framework is to use the pre-made functions within it.
There are many helpers in codeigniter to do this kind of thing.
I use the following folder structure:
application
system
static
admin
js
css
images
public
js
css
images
uploads
original
thumbs