Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Eric Rasmussen
UNL-CMS
Commits
276dde71
Commit
276dde71
authored
Jun 19, 2013
by
Eric Rasmussen
Browse files
[gh-677] Add OG path token to the UNL module
parent
d3ecb74d
Changes
2
Hide whitespace changes
Inline
Side-by-side
sites/all/modules/unl/includes/unl.token.inc
0 → 100644
View file @
276dde71
<?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
;
}
sites/all/modules/unl/unl.module
View file @
276dde71
<?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().
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment