What are the tokens available on drupal for file upload url ?
In Drupal 10, you can customize the file upload path using tokens. Tokens in Drupal are placeholders that get replaced with dynamic values when the content is being displayed or when files are uploaded.
By default, Drupal provides several tokens for use in paths. For file paths, you might use tokens related to nodes, users, or taxonomy terms, depending on where the file is being uploaded. Below are some common tokens that you can use:
- [node] Token:
[node:nid]
: The node ID.[node:title]
: The node title.
- [user] Token:
[user:name]
: The username.[user:uid]
: The user ID.
- [current-page:title] Token:
[current-page:title]
: The title of the current page.
- [current-page:path] Token:
[current-page:path]
: The path of the current page.
- [current-page:url] Token:
[current-page:url]
: The URL of the current page.
When creating a file field on a content type, you can set the file directory using these tokens. For example, if you want to organize files by user, you might set the "File directory" field in the file field settings to something like users/[user:name]
.
Here's a step-by-step guide:
- Navigate to "Structure" > "Content types" > "Your Content Type" > "Manage fields."
- Edit the file field for which you want to customize the upload path.
- In the field settings, find the "File directory" setting.
- Enter the desired path using tokens. For example, you might use
[user:name]/files
.
Keep in mind that token availability may depend on the specific modules you have installed. Additionally, token support might vary for contributed modules.
If you need more advanced token functionality, you might want to consider using the Token module or other contributed modules that provide additional tokens and customization options. Always refer to the documentation for the specific modules you're working with for the most accurate and up-to-date information.
Comments