Welcome Guest, Not a member yet? Register   Sign In
Routing question
#1

[eluser]J3roen[/eluser]
Just working on my first real project using CI and I stumbled upon a routing question.

Situation:

/controller/method/possibly/some/extra/vars/name.extension
/js/load/h/100/w/250/somefile.js (for example)

This works perfectly; then I thought why not use it for CSS also using a route.

/css/load/h/100/w/250/somefile.css

How can I get this to work? The segments between load and somefile are all optional could even be more segments.

Obviously just routing css to js doesn't work. Any help appreciated! Smile
#2

[eluser]Edemilson Lima[/eluser]
Javascript, CSS and image files must be directly accessed by the browser. They are not managed by CodeIgniter as I understand. Where do you plan to put these files? In the views folder? Such folders are for PHP files only, because the files there are executed by CI. If you are rewriting the URL with htaccess, you must configure it to allow the JS, CSS and image folders to be visible.
#3

[eluser]J3roen[/eluser]
thanks for your reply; I understand what your saying but there are cases where you want to have your CSS or JS dynamically created. For instance, to overcome some browser bugs (and you want to have an absolutely clean CSS file i.e. no hacks) you could decide to sniff the browser and serve a specific CSS for a certain browser.

In my case I have a /static/css /static/js /static/images etc. etc. which I plan to serve most of the files. But the ability to also have dynamic JS and CSS is also needed.

I fixed the problem now in another way, but for future reference it would be nice to know how I could have fixed it with a route.




Theme © iAndrew 2016 - Forum software by © MyBB