Drupal – Create New Node With PathAuto

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)

Here is a sample code to create a new page node in Drupal with the “node_save()” and adding the pathauto page.

// Bootstrap Drupal
include_once ‘includes/bootstrap.inc’;
include_once ‘./sites/all/modules/path/path.admin.inc’;
include_once ‘./sites/all/modules/path/path.module’;
include_once ‘./sites/all/modules/node/node.module’; 

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$node = new stdClass(); 

$node->type = ‘page’;  

$node->title = “Page Title”; 

node_save($node); 

$node = node_load(array(‘title’=>$node->title)); 

$path = “node/” . $node->nid; 

$alias = “some/specific/path”; 

path_set_alias($path, $alias);

Related Tech posts:

  1. Drupal Admin Page Is Blank
  2. How to import data into drupal?
  3. How to install google map in drupal?
  4. Drupal “Page Not Found” Error on ALL Pages
  5. Drupal XML sitemap not building
  6. Basic Drupal Modules for a Website
  7. How To Store Session Cookies in Drupal?
  8. How To Move The Exchange CMS To Passive Node From Active Node?
  9. Drupal Installation

About the Author