Fix url aliases of group content types
Backport node:commons-groups-first-group token from Commons 7.20 to correctly insert the group name into a group content url. This part was broken in Commons 7.15. Change-Id: Iaf3e38186200384cc3624461078ecd65342ff29f
This commit is contained in:
parent
887eaedb5d
commit
b8915f77ba
@ -508,6 +508,10 @@ function commons_groups_token_info() {
|
||||
'name' => t('"In groups" text'),
|
||||
'description' => t('The text (starting with "in the groups") indicating which groups a peice of content belongs to.'),
|
||||
);
|
||||
$tokens['node']['commons-groups-first-group'] = array(
|
||||
'name' => t('First Group'),
|
||||
'description' => t('First group associated with a piece of content. Useful for path aliases'),
|
||||
);
|
||||
$tokens['node']['commons-groups-group-contributors-count-topics'] = array(
|
||||
'name' => t('Commons Groups: Group contributor count and topics'),
|
||||
'description' => t('Displays text showing the number of contributors and the topics associated with a group node.'),
|
||||
@ -578,6 +582,26 @@ function commons_groups_tokens($type, $tokens, $data = array(), $options = array
|
||||
return $replacements;
|
||||
}
|
||||
}
|
||||
if ($type == 'node' && !empty($data['node'])) {
|
||||
if (!empty($tokens['commons-groups-first-group'])) {
|
||||
$group = $data['node'];
|
||||
$text = '';
|
||||
|
||||
if (!empty($group->og_group_ref[LANGUAGE_NONE])) {
|
||||
$wrapper = entity_metadata_wrapper('node', $group);
|
||||
$groups = $wrapper->og_group_ref->value();
|
||||
|
||||
// Return the title of the first group associated with this node.
|
||||
$first_group = array_shift($groups);
|
||||
|
||||
// Use the title field by default and fall back to the node title.
|
||||
$first_group_wrapper = entity_metadata_wrapper('node', $first_group);
|
||||
$text = isset($first_group_wrapper->title_field) ? $first_group_wrapper->title_field->value() : $first_group_wrapper->label();
|
||||
}
|
||||
$replacements['[node:commons-groups-first-group]'] = $text;
|
||||
return $replacements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function commons_groups_message_partial_default() {
|
||||
|
@ -172,7 +172,7 @@ function commons_groups_strongarm() {
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = 'pathauto_node_pattern';
|
||||
$strongarm->value = 'groups/[node:og-group-ref:0:title]/[node:title]';
|
||||
$strongarm->value = 'groups/[node:commons-groups-first-group]/[node:title]';
|
||||
$export['pathauto_node_pattern'] = $strongarm;
|
||||
|
||||
return $export;
|
||||
|
@ -323,7 +323,7 @@ function commons_q_a_strongarm() {
|
||||
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
|
||||
$strongarm->api_version = 1;
|
||||
$strongarm->name = "pathauto_node_answer_pattern";
|
||||
$strongarm->value = 'groups/[node:og-group-ref:0:title-field]/[node:field-related-question:title-field]/[node:title-field]';
|
||||
$strongarm->value = 'groups/[node:commons-groups-first-group]/[node:field-related-question:title-field]/[node:title-field]';
|
||||
$export["pathauto_node_answer_pattern"] = $strongarm;
|
||||
|
||||
return $export;
|
||||
|
Loading…
Reference in New Issue
Block a user