0

How can I remove the "node" part from "node/add" URLs? I have clean URLs on, and I have successfully used Pathauto to remove "node" from other paths.

  • 4
    You can't remove it. You can add an alias on top, as suggested in the answers, but node/add will always be at node/add. – Letharion Feb 26 '12 at 16:08
5

If you go to admin/config/search/path/add then you can easily alias node/add/type to whatever you want. For example, if you're using a node type called contact-form for a contact page, then just add contact-form as an alias for node/add/contact-form.

2

Enable the Path module (in core), and add a new alias.

2

If you wanted to create a different path from which you can add nodes, you could also do something along the lines of...

function mymodule_menu() {

  $items['add/%'] = array(
    'title' => 'mymodule add',
    'page callback' => 'mymodule_add',
    'page arguments' => array(1),
    'access callback' => TRUE, // or set to your specifications of your site
    'type' => MENU_CALLBACK,
  );

  return $items;

}

function mymodule_add($type) {
  global $user;

  module_load_include('inc','node','node.pages');
  $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type, 'language' => '');

  return drupal_get_form($type .'_node_form', $node);
}

...in a module. I say along the lines of because a) that's a drupal 6 example and I know you said drupal 7, and b) no security is included in the above either. But at least I hope it's showing how easy it is to extend things. Also, you just have to make sure there are no namespace collisions, because, unless your "mymodule" is named "add," it is being somewhat rude by claiming "add" as its own.

0

You can get the aliases you want created automatically with the Sub-pathauto module

(Sorry it's a rather late answer, but hopefully a more useful one for some readers.)

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.