ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Redirecting outbound links

May 03, 2012 11:06am

Subscribe [2]
  • #1 / May 03, 2012 11:06am

    wizs

    35 posts

    Hi,

    Hope you can help 😊

    I have a directory-style site and list lots of outbound links. At the moment I’m linking directly to the URLs using a custom field. However, I’d like to redirect each link so I’m not linking directly. Is there a way to do this or would I need a plug-in of sorts?

  • #2 / May 03, 2012 5:57pm

    Rob Allen

    3114 posts

    Not tested but I’d look at routing outbound links through a template and using the redirect= variable

    Example:

    1. Set up a template group called “go” (or whatever you want to name it)

    2. Add a tag to the “go” index template to hold the redirect and the URL:

    {exp:weblog:entries entry_id="{segment_2}"}
    {redirect='{url_custom_field}'}
    {/exp:weblog:entries}

    ... where {url_custom_field} holds the address of the site you’re linking to

    3. Update the link href in the directory entry template:

    <a href="http://{entry_id_path=go/index}">Link title</a>

    ... this should output a path with the entry ID in it, eg yoursite.com/go/123

    Now when you look at an external link it will display as a URL on your site, but when clicked should just forward the user to the remote site.

     

  • #3 / May 04, 2012 9:41am

    wizs

    35 posts

    That sounds great, I’ll give it a try! Thanks Rob 😊

  • #4 / May 04, 2012 12:27pm

    Dan Decker

    7338 posts

    Hi wizs,

    Looks like Rob has provided a workable solution!

    Is there anything else I can assist you with?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases