0

I have a relationship problem and I figured Stack Exchange can help ;)

I'm using the standard relationship field in EE 2.8.1 but the conditional statement just keeps throwing an error;

{cf_campaign_accommodation}
{cf_campaign_accommodation:placetostay_addressline1}
{if "{cf_campaign_accommodation:placetostay_addressline2}" != ""}{cf_campaign_accommodation:placetostay_addressline2}, {/if}
{/cf_campaign_accommodation}

{cf_campaign_accommodation} is the relationship field. When I load the template, Google Chrome throws a "This site can't be reached. ERR_CONTENT_DECODING_FAILED" error.

I have also tried the following but neither of these work;

{if '{cf_campaign_accommodation:placetostay_addressline2}' != ''}{cf_campaign_accommodation:placetostay_addressline2}, {/if}

{if cf_campaign_accommodation:placetostay_addressline2 != ""}{cf_campaign_accommodation:placetostay_addressline2}, {/if}

Wondered if anyone else has seen a similar issue or knows of a solution?

Thank you.

0

An error reported by Google Chrome won't be linked to a problem with this field - you'd get an error from EE (what kind depends on what the error is).

If you are not seeing an EE error perhaps this code is working OK and the error is somewhere else.

A good simple check is simply to temporarily remove the {if} clause and output the content of the field always - just so you can make sure that the field is generating the content you expect.

If it is, then you can review the {if} logic again confident that you know what content is etc. If when you find that the field is always blank then you need to track down where the missing information is...

Another option would be to change the logic - you could use something like this:

{cf_campaign_accommodation}
  {cf_campaign_accommodation:placetostay_addressline1}
  {if ! cf_campaign_accommodation:placetostay_addressline2:no_results} 
    {cf_campaign_accommodation:placetostay_addressline2}, 
  {/if}
{/cf_campaign_accommodation}

I've not tested this and wonder about the use of the ! operator - but if that doesn't work you could do something using {if:else} such as:

{cf_campaign_accommodation}
  {cf_campaign_accommodation:placetostay_addressline1}
  {if cf_campaign_accommodation:placetostay_addressline2:no_results}
    {!- Do nothing -}
  {if:else}
    {cf_campaign_accommodation:placetostay_addressline2}, 
  {/if}
{/cf_campaign_accommodation}

HTH

| improve this answer | |
  • Thanks Gavin, my template only has the above code actually with the exception of the wrapping exp:channel:entries tag. When I remove the conditional around {cf_campaign_accommodation:placetostay_addressline2} the template loads fine. – doubleplusgood May 11 '16 at 8:57
  • Hi - yes I imagine it does - but the operation of an {if} conditional in EE won't itself cause an ERR_CONTENT_DECODING_FAILED error. FWIW the error itself seems to be one linked (around web) to issues associated with gzip compression in Apache. My best guess is that whatever is in the {cf_campaign_accommodation:placetostay_addressline2} field is not what you think it is - hence my suggestion that you simply dump out whatever the field will generate and see what you get... – JCOGS Design May 11 '16 at 11:39
  • I've added some ideas for alternative {if} logic you could use - maybe just changing the way you do this will sidestep whatever the problem is. – JCOGS Design May 11 '16 at 11:53

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.