Welcome Guest, Not a member yet? Register   Sign In
Load CSS/JS dynamically in header.php depending on current view
#1

[eluser]Unknown[/eluser]
I searched around a little and didn't find any good solutions for this, but I'd like to load up CSS files in views/templates/header.php depending on which view I'm on.

For example, my directory structure is as follows:

<pre>
views
--- account
--- dashboard
content
--- css
------ app
--------- account
------------ index.css
--------- dashboard
------------ index.css
</pre>

So if I make the following request: http://localhost/account/settings

... I want to be able to load my CSS file located at content/css/app/account only. Likewise, if I hit my dashboard view I only want to load the CSS located at content/css/app/dashboard. Within header.php I'd be generating the include something like this:

Code:
&lt;link rel="stylesheet" type="text/css" media="screen" href="content/css/app/$view/index.css" /&gt;

... where $view is the current view that I'm on.

My JS is structured similarly and I'll be loading that from views/templates/footer.php.

Suggestions? I know this is probably simple but a big brain fart at the moment.


Messages In This Thread
Load CSS/JS dynamically in header.php depending on current view - by El Forum - 03-10-2013, 09:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB