There's been a change in Drupal for 4.7. The base href statement is no longer included in the header information for Drupal page output. This now changes the way that relative links have to be expressed in a Drupal site. Previously, to link to a Drupal node such as
http://example.com/drupal/node/1000
one would create a relative link in an a href statement like this
<href="node/1000">
Now, with the absence of the base href statement, the relative link is written relative to the domain name like this
<a href="/drupal/node/1000">
I have no idea what the benefits are for doing this, but I have encountered three major problems as a result of this change:
- User expectations. People who are used to Drupal 4.6 and earlier will not realize that they need to switch the way that the define relative links. There is no information about the missing base href statement that I could find in either the CHANGELOG.txt or UPGRADE.txt file. Even if this information is made available in those files, this is still likely to cause a lot of support problems.
- Inadequate update to new URL format. As I understand it, Drupal 4.7 update.php will rewrite relative URL's in existing 4.6 sites to the new URL format for 4.7, but only in nodes and comments. This means that anyone who has used relative URL's in blocks, mission statements, footers, submission explanations, etc. will have to update those URL's by hand. Furthermore, as previously mentioned, there is no explanation about this necessity in UPGRADE.txt.
- Inability to move Drupal sites from folder locations. Here's one of the biggest problems, and one that will likely affect developers more than anyone else. If you build a site in http://example.com/drupal/, all of the relative URL's that the content might include have to be expressed in terms "/drupal/..." (see above). If you then move the site to another folder location or a root domain, the URL's cease to function.
Maybe this more gripe than a real possibility to affect change, but this seems to be a real usability issue. I know I can go into my PHPTemplate page.tpl.php file and add in the base href statement. But how many other people will know this? Even thought this might have been decided by a majority of developers on the development list, I suspect that a very large percentage of the Drupal community would be better served if the base href statement were added back in. And if there are indeed great benefits for everyone in making this change, then consider this a gripe that just the means to get the word out so that people understand what they need to expect.
Comments
CSS layout affected also
Yes, this has already bitten me in the ways you mention.
One additional thing: I always used to save-to-file a page of the Drupal site to do CSS layout with Dreamweaver. Without the base statement, this doesn't work easily any more.
Your "new" relative link is wrong
Let me quickly correct something you wrote, so that others don't repeat your mistake. You state:
Without a
<base href>tag, you will need to write your new relative links like this:<a href="/drupal/node/1000">(Note the leading slash in the url.)
- John (JohnAlbin)
thanks
Mistype. Had it right later on when I discussed it more. I edited the post and fixed it.
Reasons
There were several reasons for removing the base tag. Many bad search engine spiders got confused by it, resulting in endless fetches for urls like
node/node/node/node/node/node/node/...which could hammer a server severely. And links to anchor tags required the current page's path, which many people complained about.I remember someone quoting an authorative source stating that using the base tag to indicate anything other than the document's real base URI was bad behaviour.
Anyway, Drupal is not set in stone. If the blocks and missions are not being updated, we can still change that.
--
If you have a problem, please search before posting a question.
Link
That would have been Morbus at http://drupal.org/node/13148#comment-69231.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Additional link
The
base hreflink was supposed to be only for specifying the URL "when the document is read out of context.http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.2.2
The reason for it's existence was removed from later html specs. But it's plain to see that specifying anything but the actual URL is problematic.
- John (JohnAlbin)
that makes sense, but Drupal is an archive
That makes sense from the browser perspective of accessing files on the site. However, it doesn't help that Drupal needs a way to specify URL's relative to Drupal, the example being the problem with moving the site mentioned above. Think of Drupal as an archive. It needs to be able to manage relative URL's based on the inputted $base_URL. Seems like the best solution would be filter than allows one to input URL's on Drupal relative to the installation, but rewrites them appropriately in HTML output so that a base href statement is not needed.
Anyway, thanks for the clarification.
blocks and missions
I don't honestly know from experience whether anything else other than nodes and comments is being updated; I'm not going to convert any of my sites until I am ready deal with broken links. Just going off what you told me :)
The reasons for the change
I've happened upon the reasons just last week, so I'll try to explain.
<a href="#mylink">) don't work in Drupal 4.6 and before. if you are putting a named link in a node, you have to know the node's url before writing part of the node's content (which is kind of a pain). But more importantly, if you want to put a named link in your template, you'll need to learn php in order to insert the current url into the named link (i.e. it's difficult for template writer's to do something simple.)<base href>and fill the watchdog and apache logs full of 404 errors.You can see a mind-numbing discussion of the issues in this developer thread: http://drupal.org/node/13148
If what you say about the documentation is true (I haven't checked yet), this is a major upgrade issue. And should be right at the top IMHO.
- John (JohnAlbin)
testing the base element
I have been testing the base element for a few days now.
In page.tpl.php of my theme, I put in the header :
<base href="http://www.myWebSite.com/" />About the issues you report.
1. Named links don't work indeed. After adding back the base element in my Drupal 4.7.4 installation, I realized that all collapsible fieldsets (such as in the node edit page) make use of the "href" node attribute in DOM scripting. To make the fieldset title "clickable", collapse.js creates a link element, and assign to its onclick property the function that will make the fieldset collapse. Instead of adding an onclick event-handler property to the existing element. The code is like this, in collapse.js :
In Internet Explorer 7, even when you set the event-handler to false, the link is still followed in its non-Javascript usual way, after the function assigned to the event-handler is invoked. As a result, when you try to open and close the collapsable fieldsets, you are redirected to the web site home page : http://www.myWebSite.com/#
I fixed collapse.js because it's bad practice anyway to add an href attribute just to make the pointer cursor appear when you are hovering over the element... Here's what I did (I don't think it's the absolute best fix though, the best would be to avoid the creation of that anchor element) :
a.href = "#";And my stylesheet, I added :
Now, about the so-called limitation here of having to put :
href="node/6/#", instead ofhref="#"when trying to access some IDed element on the same page, I find it a non-issue.2. As far as the second problem you mention, I am not aware of experiencing it so far.
What I know, though, is that the base element is XHTML-strict compliant. So the argument that the removal of the base element is necessary to be more W3C-compliant is wrong.
Please submit an issue
I don't know the merits of your solution, but if you wish to discuss this further and result in a change in drupal, please submit an issue against the drupal project.
----
Previously user Ramdak.
I asked for help with this already
And the update should go here: http://drupal.org/node/57649
I made an appeal to the docs team and supplied an intial list of items that I could remember as needing attention. Feel free to do a write up. I've done most of the pages there already and would rather not do them all. So far the response has been underwhelming and I've only played World of Warcraft twice in voer two weeks.
http://lists.drupal.org/archives/documentation/2006-03/msg00148.html
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
Another problem with this.....
I'm not sure if this is related, but I added some content to my site today (running 4.7 RC2) and the log entry in Drupal, under Details, lists the link to the content as:
Location: /node/85/edit
Clicking on that link, of course, doesn't work..... not sure if it would work without the "/" in front (which Drupal added automatically), but without the base url kicking in it sure isn't working now......
any solution for moving Drupal sites?
Any ideas about how to deal with moving Drupal sites to different directory location (see orginal post)? The only thing I can think of is to download the db, then do search and replace on specific tables.
This would be of some importance to come up with the best strategy for before the stable release. Many people are bound to build their new, 4.7 production site in a different location than the intended place in the domain and then move it.
You could use a subdomain
You could use a subdomain instead. Or you could make a script based on the update.php script that changes your links later. Or you could simply avoid adding links by hand and use some output filter.
--
Drupal services
My Drupal services
--
Drupal services
My Drupal services
subdomain
The subdomain sounds like the best solution for those that have that capability. Certainly the easiest.
Many people are bound to
Sigh:(
This is exactly what I was planning to do. Looks like more work in the offing unless some kindly soul comes up with a neat solution.
Filter module to insert base path
I've got a filter module working that inserts the base url into links - its just something I threw together to help with a site migration. The trick is to get it to work you have comment out the update in updates.inc that "fixes" relative urls.
Let me know if you're interested and I can email you a copy.
Overview of changes and consequences
I've written this up as instructions about changes in 4.7. If anyone has any changes to suggest, let me know.
I am definately no expert on
I am definately no expert on this but would not .htaccess be able to compensate for changes when using a subfolder?
That's what I've been doing.
That's what I've been doing. I believe that's how WordPress used to handle it too.
Actually, there is a great way to rewrite arbitrary subdomains to subfolders that comes in real handy if you want to stage a bunch of websites in subdirectories of a single domain but maintain their DocumentRoot portability.
The following technique (attributed to Andreas Friedrich over at webmasterworld) will rewrite...
subdomain.example.com/path --> example.com/subdomain/path
*Of course for this to work you will need to have a DNS record for each subdomain. A wildcard ( *.example.com) is usually the easiest way to cover everything.
-zach
------------------------
harkey design
: z
:)
A hidden gem. Thanks spiro for having led me to this discussion.
Caroline