We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Encode url titles into a difficult to guess number?

How Do I?

wbjp's avatar
wbjp
89 posts
about 5 years ago
wbjp's avatar wbjp

Hi. Just wondering if there is a way to automatically encode url titles into a long difficult to guess number? Thanks

       
Rob Allen's avatar
Rob Allen
2,950 posts
about 5 years ago
Rob Allen's avatar Rob Allen

You could try obfusticating the value using https://docs.expressionengine.com/latest/templates/variable-modifiers.html#rot13 or https://docs.expressionengine.com/latest/templates/variable-modifiers.html#encrypt but if you’re using the url_title to pull in entries based on the URL segment it obviously wouldn’t work.

I’m wondering what the use case is for doing this?

       
wbjp's avatar
wbjp
89 posts
about 5 years ago
wbjp's avatar wbjp

Sorry for my poor explanation. Currently I am using entry_id to get a numerical urls like mydomain.jp/entry/50 but I would like the number to be longer and not in any particular sequence.

       
Tom Jaeger's avatar
Tom Jaeger
228 posts
about 5 years ago
Tom Jaeger's avatar Tom Jaeger

Just to confirm, your looking for something like a UUID to use in a URL to get away form the entry_id. Assuming that is the case, I don’t know of a way to do that natively (or of an add-on available for it).

I also know that https://hashids.org/ is used on a lot of applications.. While it’s not 100% secure (can be brute forced to get the ID). It does provide a layer of obfuscation, and probably wouldn’t be too hard to implement.

You have me thinking on the UUID front though as a whole. I’m going to add that as a formal feature request.

Other then that, the suggestion Rob had isn’t a bad one. You would have to encrypt the url_title and decrypt it and pass it into your channel entries loop as a parameter.

       
lagring's avatar
lagring
1 posts
about 5 years ago
lagring's avatar lagring

How about implementing this idea as an extension that changes the actual url_title to whatever format when an entry is saved?

That way it only needs to add extra processing on save, with no encode/decodes needed later on, nor changes to the current code.

       
wbjp's avatar
wbjp
89 posts
about 5 years ago
wbjp's avatar wbjp

Yes, I am looking to a UUID to use in a URL to get away from the entry_id. https://hashids.org/ offers exactly what I was looking for. Thanks for your advice.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.