Handling static files
Hi, is there any best practice on how to handle for multiple dynamicsites static files "css/js" etc.. ?
Regards,
Olivier.
That would be good to document in the examples. I've got an apache configuration that has a shared static directory for a bunch of sites, but separate upload and media directories per-site. That's the closest thing I have to a "best practice"
I'll add it to the cms_example and try to document it.
Hi,
I was playing around with the same idea about the css/js files.
First thing I did was to use the request.dynamicsites_folder_name in the template, but this does not have any fallback mechanism. So I created myself a template tag instead. This tag checks for each directory in 'STATICFILES_DIRS' if if can find the requested css/js file in the directory which corresponds to the site name (www_yoursite_com), if not it checks the common directory. Finally, if nothing can be found, it returns by default the {{ STATIC_URL }} /css/filename
If you are interested, I can upload the files...
Next to this, I was playing around with a CMS in which you can upload the media files. My idea was to allow each site to have staff members who can upload their own files. It was working perfectly... Then I realised that as an administrator, I would like to change my site and be able to have the media files from the selected site, no matter which initial domain I had selected. What I did was to add in addition to the dynamicsites_folder_name the dynamicsites_session_folder_name to the request, which is based on the site_id from the session. Using this, I was able to allow my admin to change sites within his session without the need to change domain.
If this does interest anyone, I can upload this as well.
Regards,
ndelacour, please do share that, thanks!
@ndelacour I too would find this interesting!