When documentation fails, go to the source

Benjamin Melançon's picture
Submitted by Benjamin Melançon on 2010, August 4 - 13:00

Tags

  • unfinished
  • When things are terribly documented, we go to the source. No, we don't bang on the developer's door at three in the morning and demand an explanation. We look at the source code.

    We want to know what are the default theme features which can be toggled on or off. Searching for one of them, 'Shortcut icon', in the code brings us to modules/system/system.admin.inc where they were all defined. (Of course, once we've found this out for ourselves we document it on the best handbook page we can find, in the Theming Drupal 6 and 7 section, http://drupal.org/theme-guide/6, "Making settings available to the administration page": http://drupal.org/node/221905)

    Need to figure out what tokens are available? Code again. The modules/user/user.tokens.inc file lays them out nicely in function user_token_info().

    <?php
    /**
     * Implements hook_token_info().
     */
    function user_token_info() {
     
    $types['user'] = array(
       
    'name' => t('Users'),
       
    'description' => t('Tokens related to individual user accounts.'),
       
    'needs-data' => 'user',
      );
     
    $types['current-user'] = array(
       
    'name' => t('Current user'),
       
    'description' => t('Tokens related to the currently logged in user.'),
       
    'type' => 'user',
      );

     

    $user['uid'] = array(
       
    'name' => t('User ID'),
       
    'description' => t("The unique ID of the user account."),
      );
     
    $user['name'] = array(
       
    'name' => t("Name"),
       
    'description' => t("The login name of the user account."),
      );
     
    $user['mail'] = array(
       
    'name' => t("Email"),
       
    'description' => t("The email address of the user account."),
      );
     
    $user['url'] = array(
       
    'name' => t("URL"),
       
    'description' => t("The URL of the account profile page."),
      );
     
    $user['edit-url'] = array(
       
    'name' => t("Edit URL"),
       
    'description' => t("The url of the account edit page."),
      );

     

    $user['last-login'] = array(
       
    'name' => t("Last login"),
       
    'description' => t("The date the user last logged in to the site."),
       
    'type' => 'date',
      );
     
    $user['created'] = array(
       
    'name' => t("Created"),
       
    'description' => t("The date the user account was created."),
       
    'type' => 'date',
      );

      return array(
       

    'types' => $types,
       
    'tokens' => array('user' => $user),
      );
    }
    ?>

    For both user (a user account being acted upon) and user-current (the logged in user) the following tokens are available:

    Knowing this is such a fundamental need we also put in a patch to Drupal 7 to link to the documentation.

    A full list of tokens available is also provided by the contrib Token module, from which the core token system was originally adapted and which continues to provide enhancements over

  • Book element

  • Tip