I wanted to use the token provided by this module to feed the short URL element of the metatag module and generate the short URLs automatically and I noticed there is only a token for node's URLs.
I improved this by providing an URL wide token for every URL token defined, and because unaliased URLs are also URL-type, you get those too.
Now you can do:
[node:url:shorten], [node:url:unaliased:shorten], [current-page:url:shorten] and [current-page:url:unaliased:shorten] and any other URL token defined by the token module or any other module for that matter.
I also removed the shorten_generate_token variable. For me it really makes no sense to have it. Yes, it can have a performance impact, but the token is only generated if it's used, so you should be aware of what you are doing anyway, it's not that it will create the token URL for every single page unless you specifically instruct to do so (like I am doing with metatag module).
Then also modified the install file to clear this variable from the db, and I noticed an update from 6.x was left there, so I went ahead and removed it altogether so a slightly cleanup on the install file.
I did left the short-url there for backward compatibility so not to break anyone using it.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2317241-4-improve-token-support-D7.patch | 4.22 KB | hanoii |
| #1 | 2317241-1-improve-token-support-D7.patch | 4.27 KB | hanoii |
Comments
Comment #1
hanoiiComment #2
hanoiiComment #3
icecreamyou commentedI believe that sometimes all tokens of a given type (e.g. "node") are generated regardless of which ones are used, but it's been so long since I've looked at this that I don't remember why I think that.
Generally I'm in favor of the new tokens, but I'd really like to make sure they don't produce unexpected/unnecessary overhead before committing.
(Also, you left two stray dpm()s in the patch.)
Comment #4
hanoiiOops, attached w/o the dpm()s.
As far as the tokens being generated, well, I am certainly not a tokens expert, however, by following the code it seems that a token is only generated when the token is actually found, so I don't think how or when the generation can be triggered on its own.
Comment #6
icecreamyou commentedTested to confirm and it looks like you're right. Committed to dev. Thanks for your contribution!