Jump to content

PW Url Shortener

Recommended Posts

Did I already say that I love PW? 😄

I had to write an offer today and I wanted to link to a portfolio website that I've built, but the link was too long for the PDF. Then I wanted to use one of the url shortening services, but it felt wrong to put a link like bit.ly/409weifsd on my offer.

I then just enabled UrlSegments on my website's home.php template, added a repeater with fields "title" and "link" and put 5 lines of code to get my very own custom short-links:

$shorturl = $sanitizer->text($input->urlSegment(1));
if($shorturl) {
  $link = @$page->shorturls->findOne("title=$shorturl")->link;
  if(!$link) throw new Wire404Exception();


If you want to try it out: https://www.baumrock.com/pw-demo


Any suggestions for improvements are welcome 🙂 

  • Like 11

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...