0

I'm displaying a list of Channel entries in a "search results" page. Each item has a link to a "details" page. Right now, my URLs look like this:

domain.com/products/1/
domain.com/products/2/
domain.com/products/3/

I'd like to encrypt the entry ids when I generate the links in the search results page. In the details page, I'd like to decrypt that when I pass it as a param to {exp:channel:entries}. Is there a way to do this natively in EE? Or is there an addon that'll do this for me? Or should I enable PHP in the templates to make this happen? (other members will not have access to EE's CP, only the admin).

  • When you say 'encrypt' are you looking to just not show them in the URL? – Ian Jul 2 '13 at 13:07
  • I think so. I want my URL to look like this: domain.com/products/xA39sZ7s/ – ExpressionEngineNewbie Jul 2 '13 at 21:47
  • Does it have to be unique? You could just have a product template where you pass in that products's entry_id when it is clicked upon through embed vars for instance. Then set dynamic="no" on the channel entries tag to tell EE to ignore the URL when displaying the individual product details. Then the product ID wont be shown in the URL. – Ian Jul 3 '13 at 12:40
  • @Ian - can you please elaborate your solution and put it down as an answer? My goal is to prevent casual users from being able to access entries by guessing the URL. So, encryption/decryption was my idea how to solve this. In the loop, I was going to do something like: entry_id="{segment_2}". I'm not familiar with your "embed vars" approach. Is there a way for me to completely leave out the entry id in the URL and still access that entry? – ExpressionEngineNewbie Jul 3 '13 at 20:06
  • Would use of url_title work? – AllInOne Jul 4 '13 at 5:00
2

I would suggest you just to use pages module for Products channel and enter the random string into Page URI of Pages.

But it wouldn't be good approach to generate and enter a URI (like /products/xA39sZ7s) containing random string into Page URI each time while editing or publishing an entry. To overcome it, just develop a small extension which will do update Page URI while editing or publishing the entry.

Now your site product urls will be like domain.com/products/xA39sZ7s/.

Hope, it would help you.

| improve this answer | |
0

Maybe Encode/Decode Plugin might help? I haven't used it myself, so your mileage may vary.

From the Docs:

This plug-in is designed to help you encode and decode a string of text. Typical use would be to encode a string so it can be safely passed from one page to another in the URL. Includes support for json, base64, htmlspecialchars, htmlentities, uuencode and rawurlencode.

BASIC USAGE:

{exp:encode_decode style="url" direction="encode"}This is @/ test string{/exp:encode_decode}

| 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.