Skip to main content
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

Use hook_node_insert() where you can additionally create another node. I am not sure that the url alias will already be available. If not use the following code, found at Programmatically create alias using pathauto for nodeProgrammatically create alias using pathauto for node, to get the original URL alias and then edit it to match your criteria: module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module

/* pathauto_create_alias($module, $op, $source, $data, $type, $language) @param $module: Your module name @param $op: The operation (insert, update, return, bulkupdate) @param $source: Internal Drupal path (i.e.: node/1) @param $data: Addition data used to generate a pathalias, in this case the node object @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias */ pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' => $node), $node->type, $language->language); // Language is optional 

Set the node alias and create a node with node_save().

Use hook_node_insert() where you can additionally create another node. I am not sure that the url alias will already be available. If not use the following code, found at Programmatically create alias using pathauto for node, to get the original URL alias and then edit it to match your criteria: module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module

/* pathauto_create_alias($module, $op, $source, $data, $type, $language) @param $module: Your module name @param $op: The operation (insert, update, return, bulkupdate) @param $source: Internal Drupal path (i.e.: node/1) @param $data: Addition data used to generate a pathalias, in this case the node object @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias */ pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' => $node), $node->type, $language->language); // Language is optional 

Set the node alias and create a node with node_save().

Use hook_node_insert() where you can additionally create another node. I am not sure that the url alias will already be available. If not use the following code, found at Programmatically create alias using pathauto for node, to get the original URL alias and then edit it to match your criteria: module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module

/* pathauto_create_alias($module, $op, $source, $data, $type, $language) @param $module: Your module name @param $op: The operation (insert, update, return, bulkupdate) @param $source: Internal Drupal path (i.e.: node/1) @param $data: Addition data used to generate a pathalias, in this case the node object @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias */ pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' => $node), $node->type, $language->language); // Language is optional 

Set the node alias and create a node with node_save().

added 873 characters in body
Source Link
Potney Switters
  • 1.8k
  • 3
  • 28
  • 42

Hook intoUse hook_node_insert() where you can additionally create another node. I am not sure that the form creatingurl alias will already be available. If not use the node using eitherfollowing code, found at hook_form_alter(&$form, &$form_state, $form_id) orProgrammatically create alias using pathauto for node, to get the original URL alias and then edit it to match your criteria: module_load_include('inc', 'pathauto'); hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) fetch// include the necessary data frominc file for Pathauto module

/* pathauto_create_alias($module, $op, $source, $data, $type, $language) @param $module: Your module name @param $op: The operation (insert, update, return, bulkupdate) @param $source: Internal Drupal path (i.e.: node/1) @param $data: Addition data used to generate a pathalias, in this case the node object @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias */ pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' => $node), $node->type, $language->language); // Language is optional 

Set the form_statenode alias and constructcreate a node with node_save().

Hook into the form creating the node using either hook_form_alter(&$form, &$form_state, $form_id) or hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) fetch the necessary data from the form_state and construct a node with node_save().

Use hook_node_insert() where you can additionally create another node. I am not sure that the url alias will already be available. If not use the following code, found at Programmatically create alias using pathauto for node, to get the original URL alias and then edit it to match your criteria: module_load_include('inc', 'pathauto'); // include the inc file for Pathauto module

/* pathauto_create_alias($module, $op, $source, $data, $type, $language) @param $module: Your module name @param $op: The operation (insert, update, return, bulkupdate) @param $source: Internal Drupal path (i.e.: node/1) @param $data: Addition data used to generate a pathalias, in this case the node object @param $type: Type of content that will be used to match a pattern, defined in the backend url alias patterns @param $language: If you have a multlingual website, you need to pass the language for which you want to generate the url alias */ pathauto_create_alias('your_module_name', 'insert', 'node/1', array('node' => $node), $node->type, $language->language); // Language is optional 

Set the node alias and create a node with node_save().

Source Link
Potney Switters
  • 1.8k
  • 3
  • 28
  • 42

Hook into the form creating the node using either hook_form_alter(&$form, &$form_state, $form_id) or hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) fetch the necessary data from the form_state and construct a node with node_save().