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.

URL within custom field throwing character errors

September 12, 2010 5:09pm

Subscribe [3]
  • #1 / Sep 12, 2010 5:09pm

    webvox

    25 posts

    Using EE, current version

    I’m using an embed to add a template that includes a button linked to an external site. The link’s URL is taken from a custom text field. Here’s the code I’m using (opening and closing characters intentionally removed):

    a href=”{product-retailer-url}”>{site_url}images/assets/buynow.png</a

    The embed is appearing correctly, but when I click on the button I get the following error: “The URI you submitted has disallowed characters.” Instead of processing the URL as an external link, it’s adding it to my site’s URL: http://mysite.com/index.php/{product-retailer-url}.

    What I’ve checked:

    - the custom field is plain text field

    - I’ve turned the auto-link channel setting on and off. No difference.

    - I’ve tried both with and without http://

    - I’ve replaced the {product-retailer-url} tag with the actual URL and it works fine.

    Am I missing something here?

  • #2 / Sep 12, 2010 7:39pm

    Brandon Jones

    5500 posts

    Hi galadan,

    Do you have a link to share? Is {product-retailer-url} actually being parsed in the output template?

  • #3 / Sep 12, 2010 9:09pm

    webvox

    25 posts

    It’s in a password-protected development directory. I’d be happy to pm you the link and login if that will help.

    (product-retailer_url) isn’t being parsed. The hard-coded link (I used http://www.apple.com for testing) works fine. I only get the error if I try to pass the URL through the custom field tag. For some reason, the tag itself is being appended to my site’s URL as the second segment.

    Let me know if you’d like me to send the login info or if there’s other info I can provide. I have a number of features that need this functionality so I’m hoping it’s a fairly straightforward fix.  : )

  • #4 / Sep 12, 2010 9:17pm

    webvox

    25 posts

    A quick update:

    Using custom fields for both the url and the link content does work in one case:

    a href=”{product-photo-large}”>{product-photo-medium}</a

    Both images are set with custom fields and and the medium photo does link to the large photo. The problem seems to be specific to custom fields containing URLs. Not sure if this is relevant but thought I’d mention it.

    I tried adding the {product-retailer-url) directly to the template without the other dynamic code around it. Still get the error, so it seems to be the way the custom field is being parsed (or not in this case).

  • #5 / Sep 13, 2010 3:22am

    John Henry Donovan

    12339 posts

    galadan,

    Please double check your auto-linking in your channel setting is set to off.
    When you goto Edit that field what do you have set for Default Text Formatting for This Field under Custom Field Options?

    If it is the default XHTML set it to none please and retest

    Do you have any htaccess?

  • #6 / Sep 13, 2010 9:55am

    webvox

    25 posts

    Good morning!

    I’ve confirmed that auto-linking is turned off. The custom field format is set to none and I’ve tested it again. No change: still get the disallowed characters error and the custom field code is being added to my site’s URL.

    The only htaccess file I have is in my web root. It’s being used solely for server-level password protection of the directory. I can kill that if you think it’s a possible issue.

  • #7 / Sep 14, 2010 2:12am

    John Henry Donovan

    12339 posts

    Please check your email

  • #8 / Sep 14, 2010 12:23pm

    webvox

    25 posts

    Just submitted the info.

    A quick update: I was using a dropdown to select the embed that contains the button and external link. Thinking that might be causing the problem, I’ve since switched to using if/else. I’ve also removed the htaccess for password protection and have simply turned the system off to prevent anyone but the super admin from visiting the site.

    Please let me know if you need more info or if you have problems accessing the site. I appreciate your help!

  • #9 / Sep 14, 2010 11:05pm

    Brandon Jones

    5500 posts

    Hi galadan,

    The issue here is that while embedded templates end up as a part of the final product, they are actually parsed independently. So {product-retailer-url} inside embeds/buy-now doesn’t actually have knowledge of being inside your exp:channel:entries tag on the main products/product-detail template.

    The solution is pretty simple. Just pass {product-retailer-url} from the main template to the embed template as an embed variable:

    {embed="embeds/buy-now" product-retailer-url="{product-retailer-url}"}

    You’ll see I made the changes to the aforementioned templates and the variable is now properly parsed since its been passed through. Hope that helps!

  • #10 / Sep 16, 2010 10:33am

    webvox

    25 posts

    Thank you so much for your help: it’s very much appreciated! Thanks for explaining the fix, too. I looked at the changes and it actually makes sense to a newbie like me.  : )

    You guys rock!

  • #11 / Sep 16, 2010 4:29pm

    Brandon Jones

    5500 posts

    No problem, galadan! Glad we were able to help. Don’t hesitate with further questions.

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

ExpressionEngine News!

#eecms, #events, #releases