Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/templates/d7/hook/tokens_alter.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 /** | |
2 * Implements hook_tokens_alter(). | |
3 */ | |
4 function {{ machine_name }}_tokens_alter(array &$replacements, array $context) { | |
5 $options = $context['options']; | |
6 | |
7 if (isset($options['language'])) { | |
8 $url_options['language'] = $options['language']; | |
9 $language_code = $options['language']->language; | |
10 } | |
11 else { | |
12 $language_code = NULL; | |
13 } | |
14 $sanitize = !empty($options['sanitize']); | |
15 | |
16 if ($context['type'] == 'node' && !empty($context['data']['node'])) { | |
17 $node = $context['data']['node']; | |
18 | |
19 // Alter the [node:title] token, and replace it with the rendered content | |
20 // of a field (field_title). | |
21 if (isset($context['tokens']['title'])) { | |
22 $title = field_view_field('node', $node, 'field_title', 'default', $language_code); | |
23 $replacements[$context['tokens']['title']] = drupal_render($title); | |
24 } | |
25 } | |
26 } |