bernhard Posted October 23, 2018 Share Posted October 23, 2018 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(); $session->redirect($link); } If you want to try it out: https://www.baumrock.com/pw-demo Any suggestions for improvements are welcome ? 12 Link to comment Share on other sites More sharing options...
pwired Posted October 23, 2018 Share Posted October 23, 2018 Good find, I like it. 1 Link to comment Share on other sites More sharing options...
bernhard Posted November 2, 2018 Author Share Posted November 2, 2018 Something similar is now built into the core: https://processwire.com/blog/posts/processwire-3.0.118-core-updates/ 3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now