CodeIgniter Forums
Views URL problem. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Views URL problem. (/showthread.php?tid=57158)



Views URL problem. - El Forum - 02-21-2013

[eluser]JackU[/eluser]
My application will do 2 things.

1. Build a website and output it to be displayed in browser.

2. Build a website and output it to a zip (to be unzipped and displayed as a static page).

My Views have this structure (like a template).

Views/Blueish/index.php
Views/Redish/index.php

The actual view file kind of looks like this:
<html>
<head>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>

Now you probobly see my problem. In case 2 (where i build and zipp it). It works fine (the css stuff is also included in the zip).

But in case 1 when i just load the view and display in the css path is wrong.

So what is the best way to solve this? I really like my directory structure in the Views folder...it is easy maintained and very easy to add new "templates". So i don´t wan´t to change that.

Thanx in advance.


Views URL problem. - El Forum - 02-21-2013

[eluser]Unknown[/eluser]
Try something like this
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>css/forms.css">


Views URL problem. - El Forum - 02-21-2013

[eluser]weirdo[/eluser]
and make sure put css file/folder same level with application folder....


Views URL problem. - El Forum - 02-22-2013

[eluser]JackU[/eluser]
Thanx for the answers. But i knew i could add some folders or files at the top level. But i don´t want to do that.

Quote:So what is the best way to solve this? I really like my directory structure in the Views folder…it is easy maintained and very easy to add new “templates”. So i don´t wan´t to change that.

There are other people who will make some templates. I really don´t wan´t them to have to add stuff to 2 directories. That´s just bad structure. Isn´t there a better way to do this?


Views URL problem. - El Forum - 02-22-2013

[eluser]Aken[/eluser]
Just change the path to the CSS depending on which output mode is selected. Obviously the two won't use the same path unless you upload to two different places, so you have to take that into consideration.


Views URL problem. - El Forum - 02-22-2013

[eluser]InsiteFX[/eluser]
And the correct use of base_url() is:
Code:
<?php echo base_url('your_path.css'); ?>



Views URL problem. - El Forum - 02-28-2013

[eluser]JackU[/eluser]
Thanx guys for the tips.

I wen´t with the "manipulate link before output" way.