Using CSS in CodeIgniter MVC |
[eluser]Rey Philip Regis[/eluser]
Hi guys, I need your help, in my view "view_products.php" I need to attach an external css file "default.css" Before that here's my directory structure: code_igniter index.php license.txt .htaccess system appplication fonts ... .... and so on so what I did is: <link type="text/css" rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT'].'code_igniter/system/css/default.css'; ?>" /> also I put an .htaccess file like: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php and I saved that in the code_igniter directory {look at my directory structure above} then when I execute http://localhost/code_igniter/index.php the css didn't work. Any advice on how to correct it, so the css file will render its style to my view. Good day. Philip
[eluser]Rey Philip Regis[/eluser]
Hi guys, Ive just figured this out already using: DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] Yahooooooo............ Goooogglee............ Yes... Philip
[eluser]wr5aw[/eluser]
[quote author="rey_philip_regis" date="1225320741"]so what I did is: <link type="text/css" rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT'].'code_igniter/system/css/default.css'; ?>" />[/quote] I setup my app with a config item for the css folder then pass it to the view and do this: Code: <link type="text/css" rel="stylesheet" href="<?php echo $css_path; ?>default.css"; ?> /> My config vars for the views looks like this: Code: $config = array (
[eluser]TVB_FSU[/eluser]
Thanks ... got it working by playing with the path in the image tag and then checking the image properties on the web .. until I finally nailed it!
[eluser]wr5aw[/eluser]
Glad you got it working. And as I mentioned in another post, site_url() is from the url helper. It needs to be loaded either manually or using autoload. |
Welcome Guest, Not a member yet? Register Sign In |