Asset handling in CodeIgniter with the BASE tag |
[eluser]Phil Sturgeon[/eluser]
I just posted an article on something I thought up a few days back: Asset handling in CodeIgniter with the BASE tag. I haven't seen this suggestion posted around the forums before so thought it might be worth mentioning.
[eluser]steelaz[/eluser]
It's been mentioned a few times in this forum, but more people should be aware of <base> tag. When combined with automatic base_url (below) detection, you can copy website from http://127.0.0.1/dev/project to http://www.project.com without any modification to configuration files or templates. Code: $config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
[eluser]Phil Sturgeon[/eluser]
Who when and where? I'll kill em. I'll kill em with a pointy shoe. As for automatic base_url, that is the way I normally handle things but I take it one step further. config/constants.php Code: /* That way I can use these handy constants throughout the entire application.
[eluser]kurucu[/eluser]
I mentioned it just the other day lol. Too far away to throw a pointy shoe at.
[eluser]Phil Sturgeon[/eluser]
Just spotted that after looking over that post again. Both me and the author of the thread missed it. Nevermind, at least this explains why what and how.
[eluser]BrianDHall[/eluser]
Great stuff, thanks! As a spot of extra fun, I use: Code: if (strstr($_SERVER['HTTP_HOST'], 'localhost')) A simple hack to set a variable that I use in my database, and possibly other places, to do things only if they are on my computer and not the live server.
[eluser]Phil Sturgeon[/eluser]
Have you conidered using constants for this? How to: Support multiple production environments in CodeIgniter
|
Welcome Guest, Not a member yet? Register Sign In |