2

I created a node in drupal 7 and given it a url path alias of 'testing'. When I try to create a menu item that links to the path alias with an anchor, it throws an error enter image description here

If I do node/1#this it works, but again not with a url path alias.

Is there a work around?

4 Answers 4

4

You can add the full url with the anchor tag. Not the best for deployment but a work around.

1

I found adding the page path without it's alias would validate the form.

For example: "node/1#top"

Although, I now have an .active-trail and .active class issue on the menu item/link.

1
  • Did you ever find a solution for the active class issue?
    – sasdev
    Commented Mar 1, 2014 at 18:49
1

This works for me:

function phptemplate_url_outbound_alter(&$path, &$options, $original_path) {
    $alias = drupal_get_path_alias($original_path);
    $url = parse_url($alias);

    if (isset($url['fragment'])){
        //set path without the fragment
        $path = $url['path'];

        //prevent URL from re-aliasing
        $options['alias'] = TRUE;

        //set fragment
        $options['fragment'] = $url['fragment'];
    }
}
0

In search for an answer for my colleague I found a gist.

You guys can try it out.

https://gist.github.com/932595

I have not worked on this.

2
  • Have you used this code? Did you find it worked?
    – JamiePatt
    Commented Aug 26, 2012 at 11:16
  • @InfluenceJamie No, I have not.
    – Hari K T
    Commented Aug 26, 2012 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.