Hello

I have a problem with named anchor to navigate on one page: when I state an anchor <a name="myanchor"> and then call it with <a href="#myanchor"> drupal goes to url like this: mysite.com/myanchor instead of mysite.com/node#myanchor (?). So it just redirects me to another url instead of ancor on the same page.

How can I use anchors? How to avoid this prodlem? Maybe clean urls is a problem?

Comments

akamarvin’s picture

What's the solution ? get to know the id of your node so you can link to your anchor by using

< a href="?q=node/view/58#myanchor" > </a>

. Again (see my other posts) , it's not very professional, i got people with absolutely no html knowledge that need to write structured pages for the site.

This is an important feature that needs filters like textile and htmlarea to be customized for that in drupal !!

Steven’s picture

This is a limitation of the clean URLs system and the <base> tag. Just use the absolute URL, or the URL relative to your drupal root.

sami_k’s picture

I wrote a little module to fix this problem. It's a filter module that will automatically change href="#myanchor" to href="path/to/node/#myanchor". I really don't know how to get it added to the modules repository here. Dries, maybe you can help me out ??

Anyhow, enjoy! and PAY IT FORWARD!

http://www.etopian.net/drupal/

rayg’s picture

here's a tweak to make the regex a bit more robust:

    $pattern = '/(<[Aa]\s[^<>]*[hH][rR][eE][fF]\s*=\s*[\'"]?)#/';
    $text = preg_replace($pattern, "\\1$_SERVER[REQUEST_URI]#", $text);
Steven’s picture

There is an i modifier to make pregs case insensitive.

be9’s picture

Your webpage ceases to exist.

Where could I get the last version of your module?

glitch’s picture

or you can use

$output .="...<a href=\".request_uri()."#myanchor\">...</a>...";

request_uri() returns the uri of the page that the user is looking at that moment.

eugsadhu’s picture

Refer to my post in response to another: http://drupal.org/node/13080#comment-76974

M.J. Taylor’s picture

Update for any others trying to fix this:

Fixing page anchors problems for prior 4.7 versions are a much larger problem than expected. Please see the thread http://drupal.org/node/13148 (last 20-30 comments) for a fuller explanation. Version 4.7 will exhibit the expected behavior.