We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Issue with fluid fields and conditionals

How Do I?

Linda A's avatar
Linda A
647 posts
6 years ago
Linda A's avatar Linda A

I have migrated a channel to using a fluid field instead of the old setup of one body field and one extended text field. The fluid field includes a textarea and a grid field that of course can be used any number of times each.

I managed to sort out that the index displays only the first instance of the textarea and the first instance of the grid field even if there are more. I do that like this:

{westeros_content}

{westeros_content:westeros_text}
{if {westeros_content:count name="westeros_text"} == "1"}{content}{/if}
{/westeros_content:westeros_text}

{westeros_content:westeros_image}
{if {westeros_content:count name="westeros_image"} == "1"}
{content}
<div class="EntryImage">
<a href="http://{content:file}">{content:image:medium}</a>
</div>
{content:caption}
{/content}
{/if}
{/westeros_content:westeros_image}

{/westeros_content}

However, I would also like to offer a “read on” link IF there us more than one text field, and I can’t seem to figure out how to construct that. What I tried was this:

{if {westeros_content:count name="westeros_text"}  > "1"}
<div class="EntryExtended"><a href="http://{comment_url_title_auto_path}">read on >></a></div>
{/if}

And that gives me the following error:

Error
You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.

Parser State: Invalid Condition: Not enough operands for operator ” > “.

In Template “Announcements/index” on line 90

Removing the inner curly brackets also do not work, so I can’t quite figure out what I am missing here.

       
Hop Studios's avatar
Hop Studios
459 posts
6 years ago
Hop Studios's avatar Hop Studios

I’d try quotes around the count and single quotes inside:

{if "{westeros_content:count name='westeros_text'}"  > "1"}
     <div class="EntryExtended"><a href="http://{comment_url_title_auto_path}">read on >></a></div>
{/if}

Also, separately, are you sure that the comment_url_title_auto_path needs an http:// in front of it?

       
Linda A's avatar
Linda A
647 posts
6 years ago
Linda A's avatar Linda A

Thanks, that gets rid of the error! Still doesn’t actually give a read on link when there’s more than one instance of westeros_text, however, so I must have something else wrong with the syntax. Hrm.

       
Linda A's avatar
Linda A
647 posts
6 years ago
Linda A's avatar Linda A

Oh, and as for that http, I need to look at it. Lots of old cruft to clean up. 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.