Needs work
Project:
Token
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Sep 2018 at 01:30 UTC
Updated:
16 Jan 2026 at 14:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirYou can't, there is no such option. You could always implement your own token that returns the structure you need. Changing to a feature request but I'm not convinced that this is useful enough to be added to the module.
Comment #3
c.e.a commentedIt is indeed useful enough to be added to the module.
Plenty of cases where I want to add a random number somewhere for example to a node title just to increase the dificulty of the node to be easily found.
But i don't want to add a very long random number such as 28474973736378474 because just a shirt random number 78975 will do the job.
You could always implement your own token that returns the structure you needCan you give an example on how to ? Or maybe point to a tutorial ?
Thank you,
Comment #4
subson commentedI think this can be implemented using hook_tokens() and you can define your own [random:number] definition to return 4 digit numbers.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Utility%2...
Comment #5
murzI vote for implement this feature too, it will be very useful to distribute file uploads between subfolders. By default files are stored in "YYYY-MM" folders, but this not solve the problem when most of files are uploaded in one month (at first site filling process).
So good solution will be use token like
[random:number:10:99]for distribute files between subfolders.Comment #6
anybodyWell I guess as feature request this is a good idea. We should stick to PHP's rand function if parameters are given:
https://www.php.net/manual/de/function.rand.php
Comment #7
rokzabukovec commentedHi.
I created a patch that makes the random:number token dynamic so that the user can provide an extra parameter of a max number. For example the user can create a 4 digit random number with creating a token [random:number:9999].
Best regards and please review.
Comment #8
deaom commentedTested the functionality with different max number parameters and it works. So marking it as RTBC.
Comment #9
berdirThis seems useful but the token description needs to be updated to explain the allowed options. Tests would be good as well, not sure if we already have random number tests.
Comment #10
anweshasinha commentedHi,
I have changed the token description and re generated the patch. I have tested the patch in Drupal 10.0.12-dev and the patch was working properly in my system. Could you please review the patch
Comment #11
van.dordafog commentedreroll for v1.17