How can I use the shortener plugin to get and shorten the current URL?

I've tried both twig and plugin methods shown in the docs, but the twig method outputs the FULL url, and the plugin method doesn't work at all (no output).

Here is what I have in my template:

 {% set longUrl = craft.request.getUrl() %}
 <p>share link: <a href="{{ longUrl|shorten }}">{{ longUrl|shorten }}</a></p>

The result with this is the full URL.

My configs in the plugin settings:

enter image description here

I cleared my system cache after I updated the settings as well.

Any ideas what I'm missing here?

  • Never used the plugin, but it looks like they do some caching in github.com/aberkie/craft-shortener/blob/master/shortener/…. Maybe you've got some cached bad results. Try clearing craft/storage/runtime/cache? – Brad Bell Sep 22 '16 at 0:16
  • 1
    Are you getting any errors in devMode when you load the page that calls shortener? – Aaron Berkowitz Sep 22 '16 at 15:34
  • Just tested it, no errors at all. – ByteMyPixel Sep 22 '16 at 15:56
  • Oh! It works when I clear the custom short domain :) – ByteMyPixel Sep 22 '16 at 15:59

The issue was that the custom short name I was using (in this case the development domain) was not associated with the bitly account. Total oversight! I've removed that and it works perfectly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.