Community Documentation

Automatic path aliases for content

Last updated December 19, 2007. Created by fago on December 19, 2007.
Log in to edit this page.

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".

About this page

Drupal version
Drupal 5.x
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.