Welcome Guest, Not a member yet? Register   Sign In
CI directory structure for application assets - recommendations?
#1

[eluser]digitalformula[/eluser]
Hi all,

I've currently got my css and scripts etc in /css and /js - that works fine.

However, I'm preparing to host more than one app inside one of my CI instances - the scripts and css aren't used interchangeably between apps.

In that situation, where do you recommend the css/js/img directories live? I thought of putting them in $application_folder but then wasn't sure of the best way to access that folder from header.php and footer.php, the templates I use.

I know about APPPATH and BASE_PATH but they point to absolute folders on the server - I don't want those exposed in the markup.

Can anyone comment?

Thanks
#2

[eluser]Learn CodeIgniter[/eluser]
FCPATH will give you a path to the root where index.php is
#3

[eluser]digitalformula[/eluser]
[quote author="Learn CodeIgniter" date="1339073094"]FCPATH will give you a path to the root where index.php is
[/quote]

That's useful, thanks.

How do YOU structure your css and js files?
#4

[eluser]CroNiX[/eluser]
Code:
-system/ (not in webroot)
-webroot/
--application/
--assets/ (same level as index.php)
----css/
----js/
----img/
--index.php (has system dir defined)
Code:
echo base_url('assets/css/my_css.css');

Use base_url() to access assets (or anything else that doesn't need to use index.php)
Use site_url() to access a CI controller/method
#5

[eluser]digitalformula[/eluser]
[quote author="CroNiX" date="1339088173"]
Code:
-system/ (not in webroot)
-webroot/
--application/
--assets/ (same level as index.php)
----css/
----js/
----img/
--index.php (has system dir defined)
Code:
echo base_url('assets/css/my_css.css');

Use base_url() to access assets (or anything else that doesn't need to use index.php)
Use site_url() to access a CI controller/method[/quote]

Excellent, thanks for pointing out the base_url() and site_url() functions - they'll help heaps.

Good timing on the structure, too - that's actually what I ended up creating, before I even read this post. I think it's a structure you proposed in another forum response, actually. It's a good structure - thanks for posting. Smile




Theme © iAndrew 2016 - Forum software by © MyBB