The shorten token functionality doesn't work on D7. Patch forthcoming.

Comments

Jackinloadup’s picture

Status: Active » Needs review
StatusFileSize
new1.92 KB

Please text and review ^_^

icecreamyou’s picture

Status: Needs review » Needs work

Thanks for the patch. Comments:

  • I'd rather use hook_token_info() and hook_tokens() than their _alter() equivalents.
  • The $language_code stuff isn't used anywhere, so it should be removed.

Other than that, patch looks good.

Jackinloadup’s picture

I used the alter hooks because we are modifying the systems existing url token. without the alters it didn't seem to work. I didn't test this very long as i found the alter hooks soon after.

Another option is to create a new token like [node:shorten_url] or something.

Thoughts?

icecreamyou’s picture

Right -- we don't want to override the URL token, we just want to provide the short URL as a new token. So naming it something other than "url" seems necessary since apparently D7 has a default "url" token.

Jackinloadup’s picture

any ideas on a name?

I will re submit the patch tomorrow (12 hours) if a name has been chosen.

icecreamyou’s picture

"shorten_url" sounds fine to me.

dave reid’s picture

Related issue in Token module: #1212576: Add an [url:shortlink] and [url:canonical] token.

For this issue [node:short-url] seems a good choice. We prefer dashes in the token name where possible.

Jackinloadup’s picture

Status: Needs work » Needs review
StatusFileSize
new1.66 KB

Here is a patch to add [node:short-url] via core hook_token_info and hook_tokens.

icecreamyou’s picture

Status: Needs review » Fixed

Thanks! Committed to dev.

Buckminster_Bond’s picture

Getting the following error message on dev...

Notice: Undefined variable: replacements in shorten_tokens() (line 672 of /home/mysite/public_html/sites/all/modules/shorten/shorten.module).

Running D7.7 - all modules up to date apart from rules which is 7.2.0-beta3

I've looked at the code and tried a few changes, but am of no help!

icecreamyou’s picture

Committed fix to dev.

Buckminster_Bond’s picture

All good - thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hanoii’s picture

Issue summary: View changes
Related issues: +#2317241: Better token support