Search code examples
expressionengine

Adding Target and Title Parameters to ExpressionEngine Generated URLs


I'm trying to add a target="" parameter to an EE-generated URL.

If I turn the "Automatically turn URLs and email addresses into links?" option off, and put the following code in my template:

<a href="{caterer_website}" target="_new" title="{caterer_display_name}">{caterer_website}</a>

I get this: http://[site url]/[path]/[caterer website URL]

If I turn the option on and put the following code in my template:

{caterer_website}

I get this: http://[caterer website URL]

Is there some parameter I can add that will allow me to add a target and/or a title to the URL? I tried the obvious:

{caterer_website target="_new"}

and other variations of the same, but to no avail.

Any help is appreciated.

Thanks,

ty


Solution

  • {caterer_website} is just a variable, so won't accept any parameters (such as target="_new")

    I normally always turn off "Automatically turn URLs and email addresses into links?" as it does do some strange stuff whenever I don't want it to. But that send it shouldn't add an a tag to an existing a tag.

    Ensure your variable includes the http, or add it manually as below, otherwise the browser will automatically interpret it as a relative URL on the site. From your description it sounds as if the caterer's URL doesn't have the http:// as part of the variable, or even starts with "/".

    <a href="http://{caterer_website}" target="_new" title="{caterer_display_name}">{caterer_display_name}</a>