CodeIgniter Forums
Where to place jquery or any other globally used JS/CSS in a multi site scenario? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Where to place jquery or any other globally used JS/CSS in a multi site scenario? (/thread-27308.html)



Where to place jquery or any other globally used JS/CSS in a multi site scenario? - El Forum - 02-06-2010

[eluser]Devon Lambert[/eluser]
Just when I think I'm getting ahead of this project it finds some new way to kick me in the ass! :-(

I am building out a multiple site, and what I hope to be, robust CMS for my use. I have managed to nail down the general layout, but I am hitting a wall on how I can make use of some general location so that I can re-purpose my globally used assets, i.e. jquery is the first that comes to mind as it will most definitely be used on every site I intend to develop. I am making use of Carabiner for the asset management, which actually makes this a little bit more tricky as I need to provide it with a either a unaminous relative path OR a url. The URL option will work as a final option (linking to Google's Jquery code) but I don't like it for testing on my local server as there are times when I do not have access to the internet and would still like to program uninhibited by the connection. Also, that only fixes the issue for Jquery.

The general layout right now looks like this:

Public_HTML/
./CODEIGNITER System Folder
./CMS_APP folder/

./Site1/
../index.php
../.htaccess
../assets/
../cache/
.../assets/
.../other cache folders/

./Site2/
../index.php
../.htaccess
../assets/
../cache/
.../assets/
.../other cache folders/

I thought about creating another "Global_Assets" folder that sits at the same level as the CI System folder but I can't figure out how to get Carabiner to make use of this global folder.

Any ideas?


Where to place jquery or any other globally used JS/CSS in a multi site scenario? - El Forum - 02-07-2010

[eluser]n0xie[/eluser]
Could symlinking be an option?


Where to place jquery or any other globally used JS/CSS in a multi site scenario? - El Forum - 02-07-2010

[eluser]Jake Grice[/eluser]
Usually with MVC wouldn't you have one main view file that is your site's template? This is where you include your CSS and everything. Also include jQuery! That's what I do on http://www.digitalsuccessgroup.net

I have one main view called 'main.' Then content is loaded into it by loading $this->load->view('content/somepage', '', true); into a var like $data['content'], which is passed into the 'main' view.


Where to place jquery or any other globally used JS/CSS in a multi site scenario? - El Forum - 02-07-2010

[eluser]Devon Lambert[/eluser]
[quote author="n0xie" date="1265576733"]Could symlinking be an option?[/quote]

This may be a viable option but I would need for it to happen automatically every time a new site was created. I can read up on it and see if it works.

[quote author="Jake Grice" date="1265579388"]Usually with MVC wouldn't you have one main view file that is your site's template? This is where you include your CSS and everything. Also include jQuery! That's what I do on http://www.digitalsuccessgroup.net

I have one main view called 'main.' Then content is loaded into it by loading $this->load->view('content/somepage', '', true); into a var like $data['content'], which is passed into the 'main' view.[/quote]

The issue here is that I have separate sites, all are making use of Carabiner. Carabiner provides great options for setting up assets, even on the fly, but it gets a little tricky when I want to set a central location for re-purposed code. Templating is in place, but each site makes use of a separate theme, and thus a separate "Main" file, although in my template scenario I call it a "Layout", but the important part to note is that I would only be able to point that Layout at one location. Then of course I have a cache folder to worry about as well.

It's worth noting that this isn't a world ending scenario. I can easily store the files in a chosen site's asset folder and then link to them that way, via a url, but I was hoping for something more seamless.

All in all, I don't want to update code in various locations as well. It's the point of MVC right? Or at least of RAD and DRY.

In any event, thanks for all the help folks, you've given me some great food for thought. :-)


Where to place jquery or any other globally used JS/CSS in a multi site scenario? - El Forum - 02-07-2010

[eluser]Devon Lambert[/eluser]
[quote author="Devon Lambert" date="1265591599"][quote author="n0xie" date="1265576733"]Could symlinking be an option?[/quote]

This may be a viable option but I would need for it to happen automatically every time a new site was created. I can read up on it and see if it works.
[/quote]

Looks like Symlinks will work just fine using PHP's exec function. :-)

Thanks again n0xie! :-)