Closed (won't fix)
Project:
Drupal core
Version:
x.y.z
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
27 Feb 2006 at 19:49 UTC
Updated:
4 Apr 2006 at 22:15 UTC
Jump to comment: Most recent file
In the past we could use url() in our themes to get the absolute url. Or absolute base url.
This patch re-adds that "feature", by making $base_url available to all parts of phptemplate templates.
Very simple. But a great benefit for themers. For me, this is a must have, when making a a theme. Esp. since we no longer have th base url.
In any case, will it make upgrading themes to versions without BASE tags a lot easier.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | base_url.patch | 935 bytes | chx |
| #7 | screenshot2_0.png | 3.64 KB | guckie |
| #6 | phptemplate_engine_add_base_url_0.patch | 1.16 KB | Bèr Kessels |
| #3 | screenshot_19.png | 30.45 KB | guckie |
| phptemplate_engine_add_base_url.patch | 1.08 KB | Bèr Kessels |
Comments
Comment #1
rkerr commentedThis is must-have functionality for themes!
+1
Although I cannot confirm that this particular patch applies yet.
Comment #2
morbus iffNote that url() still works just fine by passing the $absolute parameter.
Comment #3
guckie commentedCould someone please confirm for me whether this issue is what causes the issues shown in the attached screenshot of the administer log on my test site?
Theoretically, should the base url patch clear this up?
Comment #4
Bèr Kessels commentedyou write a patch about base_url and retrieving that in the theme. you then say that the patch will make "upgrading themes ... without BASE tags a lot easier" when, in fact, if a themer wants to use base_url, then the HTML tag would have nothing to do with it whatsoever.
I do not really understand the difference. But still, this seems to be a more correct description.
Also note that we can use url(NULL, NULL, NULL, TRUE), whichs is a lot more code then a simple $base_url in your theme.
Comment #5
Bèr Kessels commentedGucky, with the attached patch, you can re-add a base tag in your page.tpl.php which will most probably fix your issue.
But I am not hundred percent sure. There are other reasons thinkable that could cause your issue.
Comment #6
Bèr Kessels commentedThis is he same patch, bu now from the drupal root. sorry for that.
Comment #7
guckie commentedThank you very much for your reply, Bèr! Your $base_url patch (and adding the tag to page.tpl.php) did indeed clear up almost all of the 'page not found' warnings I was getting.
The only ones remaining seem to be coming from the store module (screenshot attached), so I'll try to hunt down the cause of that.
I appreciate your help!
Comment #8
markus_petrux commentedMaybe, if there was a function to retrieve the base_url? ...this was suggested by Dries here.
Comment #9
guckie commentedYou are awesome! That is exactly the issue - thanks for pointing that out to me =)
Comment #10
Kobus commentedThis works (#6) indeed!
Thanks, Bèr!
Regards,
Kobus
Comment #11
robertdouglass commentedI will be using this patch on all my 4.7 installations. This is a usability issue. If we break backwards compatibiity of all themes when we have such an elegant soultion available, we're foolish. 1++ for this patch.
Comment #12
Steven commentedWhat's the fuss? Upgrading a theme takes a minimal amount of time, and themes break anyway. The only thing that needs changing for this are files referenced directly from the templates: <img>, <link> and external <script> and <style> tags. Anything in external .css files is relative to the file itself and doesn't need changing.
Takes 2 minutes to solve with find-and-replace in any text editor.
Comment #13
Bèr Kessels commentedWe get 8 +1s for the addition of a USEFULL API. And it gets wontfoixed because it is easy to solve by replacing stuff.
I am getting absolutely mad about this attitute. Why am I not allowed to choose te preferred way of dealing with MY themes.
Who gives Steven the credentials to choose whether or not I can use base url?
If someone gives me agood reason why:
* Having an API to retreive the base url, is cruft
* Having an API to re-add the base url is not wanted,
then its fine. Then close this.
This patch adds a simple API to retreive the URL of your site in your theme. Nothing more. nothing less. And certainly no fuss.
Comment #14
robertdouglass commentedI still support this patch. I would rather have $base_url available as a variable in my theme than have to call url(). And there are times in themes when you want a fully qualified URL. I don't see what the possible arguments against this patch could be. There is no performance hit that could possibly be measured, it doesn't make anything harder, it makes several things easier, and several developers of good repute have said that they would like to see it in. Perhaps the decision to close the issue could be reconsidered?
Comment #15
chx commentedSteven, for heaven's sake this is a one liner and indeed very useful.
Comment #16
Bèr Kessels commented@steven. If, for example, you feel an urge to fix the bluebeach search bug, you will find this variable in the phptemplate very usefull.
Comment #17
Steven commentedPlease, give concrete examples where this is useful.
base_path()is the preferred prefix for URLs for theme include paths, as documented on the theme upgrading guide. It generates a short relative URL which the browser will resolve correctly. You don't want bulky absolute URLs for stuff which is included on every single page.If you /do/ need the full base URL, then IMO you are doing something exotic and weird. Still, you are free to use the global $base_url, either through the
globalstatement or the$GLOBALS[]array. You don't needurl(). Why do we need a special PHPTemplate variable for this? It is hardly going to matter.PS: Bluebeach search works perfectly for me. If there are issues, please file an infrastructure bug. I'm not psychic.
Comment #18
killes@www.drop.org commentedso.