1

I have a content page that just editors need to see. So I set the pathauto to something like 'admin/page-title'. The edit-path is 'admin/page-title/edit' accordingly.

When trying to open the node in edit mode however, the first page of admin section is displayed instead of the edit form – as found under 'admin/'.

This basically is not really a problem – just took me some time to figure out that actually the 'admin' part of the URL is causing the problem. I would however really like to keep that URL structure since it would make the path consistent to the actual internal content structure. Any suggestion how I could get this work? Any pointers would be gladly appreciated.

1 Answer 1

1

It happens because paths defined through hook_menu() implementations have the precedence over path aliases. The System module defines the admin menu item, which is a catch-them-all, since Drupal, for a non existing path like node/1/not-defined-from-any-module, will show node/1. This also happens for not existing path aliases that partially match a path defined from a module; if you try to access admin/not-existing-alias, Drupal will return the page at admin.
Notice that in the case of a non existing alias that partially matches an existing one (e.g. path-alias/sub-path-alias/not-existing-sub-path versus path-alias/sub-path-alias), Drupal will not show the page at the path for the existing alias (in my example, path-alias/sub-path-alias).

Also, the Pathauto module doesn't define path aliases for node/1/edit; for that, you need the Sub-pathauto (Sub-path URL Aliases) module.

The Drupal Path module matches only full URLs when creating SEO-friendly aliases. This module extends that behavior by also matching known sub-paths and replacing them with their respective alias.

For example, if user/1 is aliased to users/admin, this module rewrites the link to the user contact page user/1/contact to use the aliased URL users/admin/contact instead. This also includes Views URLs taking a node as argument (e.g. node/%/yourview), in short, every URL that is based on, or extends, an existing alias. In combination with the Pathauto module it is possible to get rid of all remaining exposed internal non-administrative URLs.

2
  • but i can still have nodes with a url like 'admin/page-title' –– which should then also be 'overwritten' by the hook_menu() if I understood you correctly, or? Apr 25, 2015 at 15:01
  • The Pathauto module alone doesn't define aliases for node/1/edit. For that, you need the SubPathauto module.
    – apaderno
    Apr 25, 2015 at 17:39

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.