CodeIgniter Forums

Full Version: Relative includes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hi,

I was trying to do relative includes and css @imports and couldn't quite get it to work. Going through the forums I saw references to the subject, but all the places referred to using the base_url() method. I have a problem with this...
If several developers are working on the same project and each developer serves the website locally having base_url set to localhost would do the trick, but if I then want browse another developer's site those URLs would fail. This can be resolved if all developers are on the same subnet by simply having each developer set the configuration with his local IP (I don't like this as well because it means that there is a different configuration per machine). Furthermore, when the 2 developers are on completely separate LANs this would not solve the problem.

Any suggestions?

Thanks

El Forum

[eluser]Nick Husher[/eluser]
You could do a relative @import if you counted the number of segments and for each segment add "../" to the beginning of your URI you're using for your CSS file. So if your css files are in your root directory with index.php, and you get a url like "index.php/products/service/301" you'd want your relative url to be "../../../style.css"*


[ * it might also be "../../style.css" I don't know. I'm a little/a lot hungover right now. Happy New Year! ]

El Forum

[eluser]John_Betong[/eluser]
 
I think that the CSS file should be part of the application.

I have my CSS files in a ./css directory within the application folder.

Code:
<base href="<?= base_url() .APPPATH ?>" />
  <link type="text/css" href="./css/ss_green.css" rel="stylesheet" />

This is ideal for copying/zipping the whole application directory and not having to scratch around for files outside of the application. It works for both localhost and online.