CodeIgniter Forums
access main directory, how? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: access main directory, how? (/showthread.php?tid=2740)



access main directory, how? - El Forum - 08-22-2007

[eluser]snaggy[/eluser]
Here's my problem: in my view file to import for example css I write

http://www.mysite.com/themes/my_theme/css/my_css_file.css

but it should be enough this

/themes/my_theme/css/my_css_file.css

still it doesn't work, not even in JS or images or whatever else. I have no .htaccess file.

what could be causing this?


another question, I'd like to put my view file (actually through the parser) in the theme directory, or at least create a view file that loads the current theme from that directory. How can this be done? My goal is to create a simple way to add/change theme to the site


bye


access main directory, how? - El Forum - 08-22-2007

[eluser]esra[/eluser]
[quote author="snaggy" date="1187794897"]Here's my problem: in my view file to import for example css I write

http://www.mysite.com/themes/my_theme/css/my_css_file.css

but it should be enough this

/themes/my_theme/css/my_css_file.css

still it doesn't work, not even in JS or images or whatever else. I have no .htaccess file.

what could be causing this?


another question, I'd like to put my view file (actually through the parser) in the theme directory, or at least create a view file that loads the current theme from that directory. How can this be done? My goal is to create a simple way to add/change theme to the site


bye[/quote]

Try this in your theme:

Code:
<?=base_url();?>/themes/my_theme/css/my_css_file.css

To load themes from a theme-specific directory, you need to overload the view method in the Loader library. There is a section in the user guide about extending existing libraries. The current view method loads view files from the views directory. You need to add an additional search path to also look under the themes/ directory if the view file name cannot be found.


access main directory, how? - El Forum - 08-22-2007

[eluser]John_Betong[/eluser]
[quote author="snaggy" date="1187794897"]Here's my problem: in my view file to import for example css I write
...
...
...
bye[/quote]

Hi Snaggy,

With directories and paths I have found that immediately before the code which sets the path I write the following line of code to find out where I am.
Code:
<?= getcwd(); die; ?>
 
 
I have also just started using the following code in my main view file and I think it will simplify my bundled images, css, java files, etc. The files will be specific to each individual application.
[code]
<html>
<head>

<base href="http://localhost/ci_application/" />

</head>
 
Give it a try and let us know how you get on.

Cheers,

John_Betong