Commit 276dde71 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-677] Add OG path token to the UNL module

parent d3ecb74d
<?php
/**
* @file
* Callbacks for the token module.
*/
/**
* Implements hook_token_info().
*/
function unl_token_info() {
$info['tokens']['node']['og_path'] = array(
'name' => t('Group path'),
'description' => t('The alias of the group the node is in.'),
);
return $info;
}
/**
* Implements hook_tokens().
*/
function unl_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'node') {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'og_path':
if (isset($data['node'])) {
$group = field_get_items('node', $data['node'], 'og_group_ref');
if ($group != null) {
$og_path = drupal_get_path_alias('node/' . $group[0]['target_id']);
$replacements[$original] = $og_path;
}
}
break;
}
}
}
return $replacements;
}
<?php
require_once dirname(__FILE__) . '/includes/common.php';
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'unl') . '/includes/common.php';
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'unl') . '/includes/unl.token.inc';
/**
* Implements hook_help().
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment