1

I created custom node edit pages and I want the edit tab to redirect from

node/2545/edit

to

topic/2545/edit

or

node/2549/edit

to

arts/2545/edit

depending on the content type

This is not an alias this is a custom edit page/view I created, it is NOT the node edit page or an alias of it. it is a completely separate page and I simply want to redirect to this page when I click edit. In other words "I want to redirect to a completely random page when I click "edit"

enter image description here

http://screencast.com/t/zHcFsr8I

  • Are this paths an alias of node/%node/edit or a different menu callback? – jorgetutor Jun 12 '14 at 20:57
  • Have you investigated the drupal.org/project/subpath_alias module? It seems to provide what you are asking for if node/2545 is aliased to topic/2545 as an example, allowing topic/2545/edit. (I assume your node/2549 going to arts/2545 is a typo and you really meant arts/2549, too) – Jimajamma Jun 13 '14 at 15:52
1

(Disclaimer: This is not tested, it's been a while since I did a D6 site...)

First, I would implement hook_menu_alter and clone the node/%node/edit item into topic/%node/edit and arts/%node/edit. (If you want to use custom page callbacks for the forms, that's fine. You can make all changes you need to the menu items.) At least, you must change the access callback property and set it to the function name of your custom access callback (see below). Now you have three similar menu items with three different URL's. All of these should be visible as tabs on all nodes, so we're not done yet.

Second, I would create a custom access callback to hide the tabs with the incorrect URL's. This is described in HowTo: Add / Remove a menu_local_task for specific node types. In your case, the access callback should check the type of node on the current page and use it to decide if the tab must be shown or not. Don't forget to also call node_access(), because if the user is not allowed to edit that node, the tab must be hidden too.

Sorry I don't have actual code to share, I hope this helps.

1

What you are looking for is Sub-path URL Aliases

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 node/1 is aliased to content/alias, this module rewrites the link to the node edit page node/1/edit to use the aliased URL content/alias/edit instead. This also includes Views URLs taking a node as argument (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 URLs.

  • Thanks but no this is not an alias this is a custom edit page/view i created, it is NOT the node edit page or an alias of it. it is a completely separate page and I simply want to redirect to this page when I click edit. in other words "I want to redirect to a completely random page when I click "edit" – albo Jun 28 '14 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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