home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (page_title.tokens.inc)

This example Drupal source code file (page_title.tokens.inc) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, as, foreach, function, name, original, php, replacements, return, sanitize, the, title, tokens, type

The page_title.tokens.inc Drupal example source code

<?php
// $Id: page_title.tokens.inc,v 1.1.2.1 2010/11/01 21:25:40 njt1982 Exp $

/**
 * @file
 * Builds placeholder replacement tokens for page titles.
 */

/**
 * Implements hook_token_info().
 */
function page_title_token_info() {
  $info['tokens']['current-page']['page-title'] = array(
    'name' => t('Page Title'),
    'description' => t('The title of the current page, as processed by the Page Title module.'),
  );

  return $info;
}

/**
 * Implements hook_token_values().
 */
function page_title_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $sanitize = !empty($options['sanitize']);

  if ($type == 'current-page') {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'page-title':
          $replacements[$original] = page_title_get_title(!$sanitize);
          break;
      }
    }
  }

  return $replacements;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal page_title.tokens.inc source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.