Closed (fixed)
Project:
Token
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
30 Dec 2010 at 16:57 UTC
Updated:
23 Jan 2011 at 20:50 UTC
Jump to comment: Most recent file
Currently we're duplicating a lot of functionality with URL related tokens, creating separate tokens for absolute URLs, and the simple URL aliases of the path. I think it would make a lot of sense to make an [url:*] token type that has the following tokens:
[url:absolute] - The result of url() with 'aboslute' => TRUE (e.g. 'http://example.come/en/my-node-1-alias')
[url:relative] - The result of url() with 'absolute' => FALSE (e.g. '/en/my-node-1-alias')
[url:path] - The internal path of the URL (e.g. 'node/1')
[url:alias] - The alias of the URL (e.g. 'my-node-1-alias')
Any chained token should default to using absolute URLs (i.e. [node:url] would be the same as [node:url:absolute]).
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 1010822-url-token-type.patch | 20.81 KB | dave reid |
| #7 | 1010822-url-token-type.patch | 19.31 KB | dave reid |
| #1 | 1010822-url-token-type.patch | 8.02 KB | dave reid |
Comments
Comment #1
dave reidComment #3
gregglesMakes sense to me.
Comment #4
realityloop commented+1 this will be very useful
Comment #5
fagoYep, that sounds useful. However, I guess any module making use of that should introduce a dependency on the token module then? As without it the tokens would show up in token info, but not work - right? Or better, just wrap any url tokens in a module_exists('token') check?
Comment #6
dave reidActually it works pretty well. If you define a token with an undefined type, it just won't be expanded further in the token tree listings and won't work. So any module can do:
And without token module installed, using [mytype:url] works just fine (since the providing module is responsible for that), but if Token module is installed, and the module also does the following in its hook_tokens() then the url type chained tokens (e.g. [mytype:url:alias] work automatically.
Comment #7
dave reidComment #9
dave reidComment #10
fagooh, I see. That's indeed neat.
Comment #11
dave reidCommitted to CVS!
http://drupal.org/cvs?commit=477966