Skip to content
Snippets Groups Projects
  • Brian Canini's avatar
    93b654da
    Theme, JS, Custom Module, Template, and Style changes · 93b654da
    Brian Canini authored
    - adding research gall to customtoken module
    - adding variables to be used on research and research gall pages as taxonomy links
    - cleaning up .theme file
    - adding research gallery filters
    - fixing event slideshow styles
    - research and research gall taxonomy styles
    - fixing sidebar menu list styles
    - adding timer to sidebar resize js
    - adding class to sidebar via js
    - fixing taxonomy links on research and reseach gall temps
    - adding slideshow to user profile
    - adding user slideshow template
    93b654da
    History
    Theme, JS, Custom Module, Template, and Style changes
    Brian Canini authored
    - adding research gall to customtoken module
    - adding variables to be used on research and research gall pages as taxonomy links
    - cleaning up .theme file
    - adding research gallery filters
    - fixing event slideshow styles
    - research and research gall taxonomy styles
    - fixing sidebar menu list styles
    - adding timer to sidebar resize js
    - adding class to sidebar via js
    - fixing taxonomy links on research and reseach gall temps
    - adding slideshow to user profile
    - adding user slideshow template
customtokens.module 1.62 KiB
<?php
/**
* Implements hook_token_info().
*/
function customtokens_token_info() {
   $type = [
       'name' => t('Custom Token'),
       'description' => t('Tokens for custom things.'),
   ];
   $node['landingct'] = [
       'name' => t("Research Landing Page"),
       'description' => t('The node\'s Research Landing Page'),
   ];
   $node['landinggallct'] = [
       'name' => t("Research Gallery Landing Page"),
       'description' => t('The node\'s Research Gallery Landing Page'),
   ];
   return [
       'types' => ['customtoken' => $type],
       'tokens' => ['customtoken' => $node],
   ];
}
/**
* Implements hook_tokens().
*/
function customtokens_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
    $replacements = [];

    //research ct
    $nids = \Drupal::entityQuery('node')->condition('type','research_landing_page')->execute();
    $lid = array_shift($nids);
    $alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$lid);

    //research gallery ct
    $nids2 = \Drupal::entityQuery('node')->condition('type','research_gallery_landing_page')->execute();
    $lid2 = array_shift($nids2);
    $alias2 = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$lid2);


    if ($type == 'customtoken' && !empty($data['node'])) {
      foreach ($tokens as $name => $original) {
        switch ($name) {
          case 'landingct':
            $replacements[$original] = $alias;
            break;

          case 'landinggallct':
            $replacements[$original] = $alias2;
            break;
        }
      }

    }
   return $replacements;
}