Download & Extend

Create path alias when creating stub content

Project:Menu Import
Version:7.x-1.1-rc3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

First of all, I have to say that I found this module to be very helpful. However, there is one feature that I would like to see added, to make it really powerful.

The "path" feature works when linking to existing content (i.e. it will find and match an existing alias, and link the imported menu item to that node). However, it would also be nice if this would work when creating stub content as well. For example, if one of the lines is "About|about", and "Create initial content" is selected, and the "about" alias does not exist, the current behavior is to create a new node with the stub content, but it does not set the path alias to "about".

Comments

#1

I have added this feature by making the following modifications to "import.inc". Basically, you need to modify "menu_import_create_node" to accept an "alias" as an additional argument, and use that to set the alias on the node. Then, you need to add "$menuitem['path']" as an argument to both of the function calls to menu_import_create_node, which are located in "menu_import_save_menu".

...
function menu_import_save_menu($menu, $options) {
   ...
   $nid = menu_import_create_node($menuitem['path'], $options);
   ...
   $nid = menu_import_create_node($menuitem['path'], $options);
   ...
}
...
function menu_import_create_node($alias, $options) {
   ...
   if ($alias && drupal_substr($alias, 0, 4) != 'node') {
      $node->path = array('alias' => $alias);
   }
   ...
}

There may be some additional error checking that needs to be done, but assuming the menu file is a valid format, this seems to work correctly.

#2

Status:active» closed (fixed)

Done in dev version.