Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a site contain two content type:
company, which is a group node
job, which is a group post that created by company manager.
I want to generate path alias for job using following format:
company/company_nid/job/job_nid
I try with the pattern:
company/[node:og_group_ref]/job/[node:nid]
After I download the latest OG module, it works, but not work correctly.
Then I change the pattern to:
company/[node:og_group_ref:default:0:target_id]/job/[node:nid]
After this ,change the code of pathauto.admin.in from
$form[$module][$variable] = array(
'#type' => 'textfield',
'#title' => $itemlabel,
'#default_value' => variable_get($variable, ''),
'#size' => 65,
'#maxlength' => 1280,
'#element_validate' => array('token_element_validate'),
'#after_build' => array('token_element_validate'),
'#token_types' => array($settings->token_type),
'#min_tokens' => 1,
'#parents' => array($variable),
);
to
$form[$module][$variable] = array(
'#type' => 'textfield',
'#title' => $itemlabel,
'#default_value' => variable_get($variable, ''),
'#size' => 65,
'#maxlength' => 1280,
// '#element_validate' => array('token_element_validate'),
// '#after_build' => array('token_element_validate'),
'#token_types' => array($settings->token_type),
'#min_tokens' => 1,
'#parents' => array($variable),
);
This is because our token could not be recognized by token module. We do not need this validate.
After this save you config. Create a new job, and you will get the correctly alias. Such as:
company/8/job/93