Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By PawnEKG on
I am trying to use internal page links for a page that is quite long.
When I do <a name="name">name</a>
to give a reference to where the link should go.
Then at the top give call that link. <a href="#name">go to name</a>.
It takes me back to the main page when I click "go to name". The strange part is the URL for when it takes me back to the main page ends in /#name.
Anyone have any ideas? This normally works just fine for me in normal html. That is with using full html.
Comments
<base>
That's because of the base tag. For example, this site has the following base tag in its head section:
<base href="http://drupal.org/" />
This means that all links will be relative to the base url, so
<a href="#name">
will refer to http://drupal.org/#name.A flexible way to deal with this, is to use the PHP code input format instead of HTML, and use Drupal's l-function like this:
The first 'name' is the text that will be displayed as a link.
If your page is and HTTP GET...
If the page you're linking within is the result of a get, you may be better off with something like:
That seems to be working for me, when the original URL has get variables appended to it.
In my case, I'm converting some pages I had written long ago to work within drupal. Its possible noone using drupal from scratch would run into this.
DriesK's example has all the
DriesK's example has all the get variable too. On top of that, it will generate nicer drupal-specific uls.
---
if you dont like the choices being made for you, you should start making your own.
---
[Bèr Kessels | Drupal services www.webschuur.com]
There's a patch available to
There's a patch available to remove the base tag from drupal generated pages, which would allow you to create links like '#name' when you don't want to or can't use PHP code.
If that feature would be useful for you, consider adding a comment to that effect on http://drupal.org/node/13148
Treehouse
Follow Up
I just devised a simple way to do this:
I hope that helps.