Welcome Guest, Not a member yet? Register   Sign In
Load CSS
#1

[eluser]kezman[/eluser]
Hey!
I have a local project on CodeIgniter hosted on
Code:
localhost/

My .htaccess

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

My css file

Code:
.temp {
    color: red;
}

My css file location

Code:
/application/views/css/mainpage.css

My Mainpage controller looks like this Smile

Code:
class Mainpage extends CI_Controller {

public function index()
{
                $this->load->helper('url');
                $this->load->helper('html');
                $data['content'] = 'Hey...we are on main one? really??';
                $this->load->view('maintemplate', $data);
}
}

My maintemplate.php view file

Code:
&lt;html&gt;
    &lt;head&gt;
        &lt;link rel="stylesheet" href='&lt;?php echo base_url();?&gt;application/views/css/maintemplate.css' type="text/css" media="screen, projection" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
       <p class="temp">123</p>
    &lt;/body&gt;
&lt;/html&gt;

But text is not red.
1. What's wrong?
2. Is my style of placing css files good?
#2

[eluser]kezman[/eluser]
When I put JS folder in the same folder where I have index.php and changed my .htaccess to

Code:
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|css|images|robots\.txt|css)
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

I got the desired result (including JS files)

So - is /application/views/ folder forbidden for reading from views and I should replace CSS folder to root one?
#3

[eluser]Samus[/eluser]
Why don't you just create an 'assets' folder on the same level as index.php and use base/site_url to link to your css files.
#4

[eluser]kezman[/eluser]
[quote author="Samus" date="1336903745"]Why don't you just create an 'assets' folder on the same level as index.php and use base/site_url to link to your css files.[/quote]

I know it, but I want to know "best practices" of placing js/css/image in CodeIgniter.
What about Asset library?
#5

[eluser]InsiteFX[/eluser]
Best practices are what Samus mentioned above!

Code:
application
system
index.php
assets
-- css
-- js
-- images
-- etc
#6

[eluser]kezman[/eluser]
[quote author="InsiteFX" date="1336911972"]Best practices are what Samus mentioned above!

Code:
application
system
index.php
assets
-- css
-- js
-- images
-- etc
[/quote]

thanks!
#7

[eluser]Unknown[/eluser]
Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB