Welcome Guest, Not a member yet? Register   Sign In
CSS, JS, IMG...?
#11

[eluser]agartzia[/eluser]
[quote author="ekeretex" date="1201015503"]How is your directory structure organized? Is the assets folder at the same level as your index.php file?[/quote]

I've changed a couple of times, but for now it's...
Code:
+ assets
  + css
  + js
  + img
+ system
+ user_guide
+ index.php
#12

[eluser]ekeretex[/eluser]
With your structure if http://localhost shows your home page, http://localhost/assets/img/blah.jpg should show your blah.jpg image.
Does that work?
#13

[eluser]agartzia[/eluser]
[quote author="ekeretex" date="1201017673"]With your structure if http://localhost shows your home page, http://localhost/assets/img/blah.jpg should show your blah.jpg image.
Does that work?[/quote]

Yes, well, I can access this URL
http://172.26.0.99/project_ci/assets/css/style.css

In my view:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Title by now&lt;/title&gt;
&lt;link href="assets/css/style.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;

&lt;body&gt;

How I can use relative paths?
#14

[eluser]ekeretex[/eluser]
With your current setup, make the ccs path '/project_ci/assets/css/style.css'. The starting slash is important to make it absolute.
Alternatively, set the base path to 'http://172.26.0.99/project_ci/' and use either '/assets/css/style.css' or '&lt;?php echo base_url(); ?&gt;assets/css/style.css'
#15

[eluser]ekeretex[/eluser]
Update: even if you set the base path you still need to use ‘/project_ci/assets/css/style.css’ unless you include the base_url() function call
#16

[eluser]Craig A Rodway[/eluser]
This is how I do it:

I make a www folder in the same directory as system, index.php etc...

Code:
+ system
+ www
  + css
  + img
  + js

In your template/layout, you can use the &lt;base&gt; tag like this (in the &lt;head&gt; section):

Code:
&lt;base href="&lt;?php echo $this-&gt;config->item('base_url') ?&gt;www/" />

To load CSS:

Code:
&lt;link rel="stylesheet" type="text/css" href="css/screen.css" media="screen,projection" title="Screen layout" /&gt;

Images:

Code:
<img src="img/header.jpg" />
#17

[eluser]agartzia[/eluser]
Solved!

I've tried the complete path (/project_ci/assets/css/style.css) AND, here it goes the interesting part, removing the .htaccess content:

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

With full path and with no .htaccess, it worked!

Anyway, I can't point out base_url to http://172.26.0.99/project_ci/ because it must be accessed outside as well (example.com/project_ci)

Can I hide the index.php in any other way? The one in the guide doesn't work for me. I've taken a sight to the httpd.conf and it seems to be correct (AllowOverride All?)

With such a great community, it's a pleasure to code.
#18

[eluser]Craig A Rodway[/eluser]
@agartzia: Try that htaccess again but with the 'assets' folder included in the condition:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
#19

[eluser]agartzia[/eluser]
[quote author="Craig Rodway" date="1201019030"]@agartzia: Try that htaccess again but with the 'assets' folder included in the condition:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
[/quote]

Nop, it does not work. But, anyway, the application doesn't work without the index.php either.

I can live on without removing the index.php from the URI, while I'm able to use css.

Cheers!




Theme © iAndrew 2016 - Forum software by © MyBB