Please take as much as possible from the Token Extra module.

Thanks! :)

Comments

fizk’s picture

Category: bug » feature
fizk’s picture

This is the main part of the module:

/**
 * Implementation of hook_token_list().
 */
function token_extra_token_list($type = 'global') {
  $tokens = array();
  switch ($type) {
       case 'user':
            $tokens['user']['account-url-html'] = t('The HTML URL of the user\'s profile page.');
            break;

        case 'integer':
        case 'number':
            $tokens['number']['integer'] = t('The unmodified value, as integer.');
            break;
        case 'string':
            $tokens['string']['string']  = t('The unmodified value, as string.');
            break;
        case 'date':
            $tokens['date']['date']       = t("The date formatted as 01/01/1970 - 00:33");
            $tokens['date']['date-medium']  = t("The date formatted as Thu, 01/01/1970 - 00:33");
            $tokens['date']['date-large']  = t("The date formatted as Thursday, January 1, 1970 - 00:33");
            $tokens['date']['date-yyyy']  = t('The year (four digit)');
            $tokens['date']['date-yy']    = t('The year (two digit)');
            $tokens['date']['date-month'] = t('The month (full word)');
            $tokens['date']['date-mon']   = t('The month (abbreviated)');
            $tokens['date']['date-mm']    = t('The month (two digit, zero padded)');
            $tokens['date']['date-m']     = t('The month (one or two digit)');
            $tokens['date']['date-ww']    = t('The week (two digit)');
            $tokens['date']['date-date']  = t('The day of week (1 through 7, 1 = Monday, 7 = Sunday)');
            $tokens['date']['date-day']   = t('The day (full word)');
            $tokens['date']['date-ddd']   = t('The day of week (abbreviation)');
            $tokens['date']['date-dd']    = t('The day (two digit, zero-padded)');
            $tokens['date']['date-d']     = t('The day (one or two digit)');
            $tokens['date']['site-date-medium']       = t("The current date formatted as Thu, 01/01/1970 - 00:33");
            $tokens['date']['site-date-large']       = t("The current date formatted as Thursday, January 1, 1970 - 00:33");
Dave Reid’s picture

Why did you create the separate project if you wanted it merged into token? :)

fizk’s picture

Because I love creating new projects! mewhahahahahha

and adding feature requests has always taken a long time and a lot of effort to actually get included into HEAD

and I want this to be available to people right away.

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

Most of the date tokens already exist. I'm not sure what value the integer, number and string tokens are...

fizk’s picture

> Most of the date tokens already exist.

Where? I couldn't find it in the latest stable token module.

> I'm not sure what value the integer, number and string tokens are...

It's the easiest way to get the raw value of a token. I was very frustrated with the lack of this feature, so I created the token_extra module.

Dave Reid’s picture

Latest code is always in CVS (6.x-1.x-dev), not necessary the latest stable release.

Without some valid use cases, it's hard for me to understand why the integer/number/string tokens are necessary.

fizk’s picture

The valid use case is very simple, you want to obtain the original/unmodified value of a token. I frequently run into this problem when using Rules module.

There is no way to do this without token_extra right now, AFAIK.

Dave Reid’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Please file separate requests for features. Seeing how no one else has needed these tokens and there's only 11 known sites using Token Extra, this isn't something that's a huge priority.

fizk’s picture

Status: Closed (won't fix) » Active

> Please file separate requests for features.

I'm not sure what you mean, I filed this as a feature request.

> Seeing how no one else has needed these tokens and there's only 11 known sites using Token Extra, this isn't something that's a huge priority.

How many hours does it take to add this functionality? It's already written and the code works properly.

Dave Reid’s picture

Status: Active » Closed (won't fix)

It's not a proper patch against CVS and doesn't include any simpletests, which is how we accept code into the token.module.

There's four different new features here and it make sense to focus on them individually:
1. account-url-html - Not sure how this is useful.
2. number & string 'passthrough' tokens - should be its own issue
3. date-? tokens - should be its own issue since they need to use the date token helper functions
4. site-date-medium and site-date-large - should be its own issue since it has to modify the date token helper functions