Automatic path aliases for content

Last modified: December 19, 2007 - 13:35

Required modules: Path module, workflow-ng >= 1.4
Have a look at the related tutorial: http://drupal.org/node/202329

array (
  'cfg_1' =>
  array (
    '#type' => 'configuration',
    '#event' => 'node_submit',
    '#label' => 'Apply path alias',
    '#active' => 1,
    '#module' => 'workflow-ng',
    '#settings' => NULL,
    0 =>
    array (
      '#type' => 'action',
      '#name' => 'workflow_ng_action_node_path_alias',
      '#argument map' =>
      array (
        'node' => 'node',
      ),
      '#settings' =>
      array (
        'replace' => '_',
        'dst' => 'content/[node:type]/[node:title]',
        'dst_args' =>
        array (
          0 => 'node',
        ),
      ),
      '#label' => 'Set content URL alias',
    ),
    1 =>
    array (
      '#type' => 'OR',
      0 =>
      array (
        '#type' => 'condition',
        '#name' => 'workflow_ng_condition_url_has_alias',
        '#negate' => 1,
        '#settings' =>
        array (
          'src' => 'node/[node:nid]',
          'src_args' =>
          array (
            0 => 'node',
          ),
        ),
        '#label' => 'Content has alias',
        '#weight' => '2',
      ),
      1 =>
      array (
        '#type' => 'condition',
        '#name' => 'workflow_ng_condition_token_compare',
        '#settings' =>
        array (
          'text1' => '[node:nid]',
          'text1_args' =>
          array (
            0 => 'node',
          ),
          'text2' => '',
          'text2_args' =>
          array (
          ),
          'regex' => 0,
        ),
        '#label' => 'Content is being created',
      ),
    ),
    2 =>
    array (
      '#type' => 'condition',
      '#name' => 'workflow_ng_condition_alias_exists',
      '#negate' => 1,
      '#settings' =>
      array (
        'dst' => 'content/[node:type]/[node:title]',
        'dst_args' =>
        array (
          0 => 'node',
        ),
      ),
      '#label' => 'URL alias exists',
    ),
    '#name' => 'cfg_1',
  ),
)

If you want to adapt the path, you have to edit both the condition "URL alias exists" and the action "'Set content URL alias".

 
 

Drupal is a registered trademark of Dries Buytaert.