Been following a forum thread and was wondering if anyone had any input towards a way to make multi-site pathnames more manageble Thread: http://drupal.org/node/84895 The basic issue is that pathnames for a multi-site install can easily get huge. But there is strong desire to keep all site-relevant material in the /sites/sitename folder. Suggested fixes were symbolic links from drupal root direct to, say, the files folder, but that isn't portable to Windows, gets unwieldy with many sites, and doesn't account for the sites/themes and sites/modules folders. Example situtation. One codebase - two installs. CSS absolute path to background image. http://example.com/sites/example.com/files/images/background.jpg it gets worse with subdomains... http://test_layout.example.com/sites/test_layout.example.com/files/images/ba... Does anyone know a good portable workaround? Am I missing something obvious? -- Sam Tresler sam@treslerdesigns.com
On Tuesday 19 September 2006 12:34, Sam Tresler wrote:
Been following a forum thread and was wondering if anyone had any input towards a way to make multi-site pathnames more manageble
Thread: http://drupal.org/node/84895
The basic issue is that pathnames for a multi-site install can easily get huge. But there is strong desire to keep all site-relevant material in the /sites/sitename folder.
*snip*
http://test_layout.example.com/sites/test_layout.example.com/files/images/b ackground.jpg
Does anyone know a good portable workaround? Am I missing something obvious?
I've had some issues with multi-site recently myself, but this isn't one of them. What exactly is the problem with absolute paths generated by the code having long names? You aren't typing them yourself, or shouldn't be. Perhaps the obvious thing being missed is that it's not a problem? Or am I just not seeing how it's a problem? :-) (I typically put all files under sites anyway, and in 5.0 the new sites/all directory encourages you do never ever put things in /modules or /themes.) -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Larry Garfield wrote:
I've had some issues with multi-site recently myself, but this isn't one of them. What exactly is the problem with absolute paths generated by the code having long names? You aren't typing them yourself, or shouldn't be.
Perhaps the obvious thing being missed is that it's not a problem? Or am I just not seeing how it's a problem? :-) (I typically put all files under sites anyway, and in 5.0 the new sites/all directory encourages you do never ever put things in /modules or /themes.)
Ahh, didn't know that about 5.0 - good stuff. Why shouldn't I be typing them myself? In many cases they are generated by drupal, but I usually use absolute paths to reference images in CSS, which I thought was a good practice to be browser compliant with some older browsers that still reference CSS off of the calling document (not w3c, but they do exist). Also, knowing nothing about javascript, I've had at least one theme break trying to reference a .js file from sites/example.com/themes on a relative path meant for the global theme directory. In page.tpl.php: "<script type="text/javascript" src="/themes/sometheme/sometheme.js"></script>" I changed to this: "<script type="text/javascript" src="<?php print base_path(); ?>sites/example.com/themes/sometheme/sometheme.js"></script>" I guess what I'm asking is, Is this right? I wouldn't think I should hardcode the site into the page.tpl.php just to get it to work in the site specific theme folder. What is the proper way to make CSS image paths, and reference javascript in themes? --Sam Tresler sam@treslerdesigns.com
If you are concerned about themes only, then you don't need to embed the full path in them. My theme is in sites/example.com/themes/themename/ The style.css file will automatically be picked up by the phptemplate theme engine if it is in the themename directory. Images referenced from the style.css will be picked up if they are relative too: list-style-image:url(images/menu-leaf.gif); The only image I occasionally need to reference is the logo, and that goes in the admin/themes page, as sites/example.com/ themes/logo.png for example. If you really want to embed images, css, or js files in your tpl.php file (which I try to stay away from) then use you can use the path_to_theme() function which will make it portable. Does that answer the question?
On Tuesday 19 September 2006 20:29, Sam Tresler wrote:
Why shouldn't I be typing them myself? In many cases they are generated by drupal, but I usually use absolute paths to reference images in CSS, which I thought was a good practice to be browser compliant with some older browsers that still reference CSS off of the calling document (not w3c, but they do exist).
Drupal doesn't support Netscape 4 anyway, so I wouldn't bother with that. :-)
I changed to this:
"<script type="text/javascript" src="<?php print base_path(); ?>sites/example.com/themes/sometheme/sometheme.js"></script>"
I guess what I'm asking is, Is this right? I wouldn't think I should hardcode the site into the page.tpl.php just to get it to work in the site specific theme folder. What is the proper way to make CSS image paths, and reference javascript in themes?
This is what you're looking for: http://api.drupal.org/api/4.7/function/path_to_theme <script type="text/javascript" src="<?php print path_to_theme();?>/sometheme.js"></script> -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
This is what you're looking for: http://api.drupal.org/api/4.7/function/path_to_theme
Yes! Thank you, and Khalid too.
Op woensdag 20 september 2006 02:58, schreef Larry Garfield:
You aren't typing them yourself, or shouldn't be.
There is one other potential issue, related to this. Two sites on a multisite: shell.com greenpeace.org With some guessing: greenpeace.org/sites/greenpeace.org/themes/logo.png shell.com/sites/greenpeace.org/themes/logo.png (look ma, shell hosts the greenpeace logo!) Not a huge issue, but it can lead to nasty issues when two sites prefer to remain unrelated. Or when other sites start linking to funny files. Did anyone find a solution for this by any chance? I've been playing with mod_suexec+file permissions and rewrite rules in the past, so far without luck. Bèr
Bèr Kessels wrote:
Op woensdag 20 september 2006 02:58, schreef Larry Garfield:
You aren't typing them yourself, or shouldn't be.
There is one other potential issue, related to this. Two sites on a multisite: shell.com greenpeace.org
With some guessing: greenpeace.org/sites/greenpeace.org/themes/logo.png shell.com/sites/greenpeace.org/themes/logo.png (look ma, shell hosts the greenpeace logo!)
that's exactly the issue in a commercial world. we have been avoiding this by still keeping the user domain directory, then create separate symbolic links for each drupal folders back to the basecode except sites/ and files/ dir. This also keeps the disk space usage of each client very clean . Will be interested to know if there is any better solutions. Jenny
participants (5)
-
Bèr Kessels -
Jenny Hsueh -
Khalid B -
Larry Garfield -
Sam Tresler