I can't get tokens to structure the subfolders for uploaded files. Tokens do not appear to be recognised: [user-name] creates a directory
%5Buser-name%5D

Is this a bug or is there something I have missed? Any help would be greatly appreciated.

I am using Drupal v 5.10

Comments

dopry’s picture

Status: Active » Postponed (maintainer needs more info)

did you enable the token.module?

jakchapman@groups.drupal.org’s picture

I also have this problem and token.module is enabled.

albert_philly’s picture

Can we get support for a wider variety of tokens? I seem to recall I used to be able to use [site-date-yyyy]/[site-date-mm]/[site-date-dd] but these are now interpreted literally.

deciphered’s picture

@albert_philly

FileField Paths adds a large range of tokens, specifically the ability to use Node based tokens.

davidwhthomas’s picture

I simply needed date tokens for the folder names.

I created a few extra tokens under the 'user' category for access by filefield

Two hooks are implemented. To use, replace 'modulename' with your module name.

<?php
/**
 * Implementation of hook_token_values().
 * Define extra tokens
 */
function modulename_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'user':
      // these tokens are for folder safe date tokens when the node object isn't available
      $values['curr-year-yyyy']   = date("Y", time());
      $values['curr-month-mm']  = date("m", time());
      $values['curr-week-ww']  = date("W", time());
      $values['curr-day-dd']  = date("d", time());
      break;
  }
  return $values;
}

/**
 * Implementation of hook_token_list().
 * Provide help text for extra tokens
 */
function modulename_token_list($type = 'all') {
  if ($type == 'user' || $type == 'all') {
    // these tokens are for folder safe date tokens when the node object isn't available
    $tokens['user']['curr-year-yyyy']   = t('Current year in yyyy format');
    $tokens['user']['curr-month-mm']   = t('Current month in mm format');
    $tokens['user']['curr-week-ww']   = t('Current week in ww format');
    $tokens['user']['curr-day-dd']   = t('Current day in dd format');
    return $tokens;
  }
}
?>

DT

quicksketch’s picture

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

Yep, any requests for more paths can go to http://drupal.org/project/filefield_paths.

varun21’s picture

using [nid] creates a directory "nid" into which it uploads the file. When you save the node, it copies this file from "nid" folder to the actually directory named after token replacement.