2022 Developer Survey is open! Take survey.
10 votes

Conditional for empty relationships field

Long time to add to this but... {relationship-field} do relationship stuff {if relationship-field:no_results} Empty stuuf {/if} {/relationship-field}
user avatar
6 votes
Accepted

EE3 - When image description is blank, use title field

Try this: <li class="large-4 small-3 columns"> {right_image_1} {if description} <img class="avatar w-alt" alt="{description}" src="{url}" /> {if:else} <img ...
user avatar
5 votes
Accepted

Conditional to show entry by date range?

The following conditional will achieve what you want: {if {current_time format="%m"} <= 6} <p>do Jan through June</p> {if:else} <p>do July through December</p> {/if} ...
user avatar
  • 266
5 votes
Accepted

Matrix Total Rows Column Search Conditional

EE simply removes any tags corresponding to custom fields that have no data. So by the time EE is ready to parse the outer {if} conditional, it will look like this: {if > 0} Try wrapping the ...
user avatar
4 votes
Accepted

Test for empty string

I believe if you use: {If your_field} something exists {/if} This should display conditional content if the field contains anything at all.
user avatar
  • 3,163
4 votes

How to hide content if channel has no entries?

Put the div tags inside your channel entries tag pair but to prevent them being output many times wrap them in conditionals. Then you can test the total results returned to decide whether to output ...
user avatar
  • 7,176
4 votes
Accepted

Conditionals from within Piped String of values

Try this: {if segment_category_ids_piped ~ '/\b'.cat_id.'\b/'} Note: this works for pipe-separated IDs (numbers). If you're looking for pipe-separated strings or text, you'd be better off using this:...
user avatar
  • 11.3k
4 votes
Accepted

Conditional if else Problem

Try this: <h3> {if long_titles} {long_titles} {if:else} {title} {/if} </h3>
user avatar
  • 5,900
4 votes
Accepted

EE: Show previous 3 blog entries prior to the current viewed entry

my guess would be you'll need an embed. the in the main template (within the channel:entries tag) call that embed something like this: {exp:channel:entries} {embed="_inc/_previous_three_posts" ...
user avatar
4 votes
Accepted

Why is the OR not working in a conditional statement?

Well here is the issue. You are trying to give OR condition for 2 strings. OR condition will return true if any one of the given statements are true. If you want to execute the code when url_title ...
user avatar
3 votes
Accepted

EE 2.8.1 relationships change

You must prefix all of the variables inside of a parents tag with parents:,including count and total_results. You also have an extra conditional which you don't need - and, note the change in ...
user avatar
  • 17.4k
3 votes

Conditional Variable with Grid Field

I tried a billion combinations as well. This is how I used it for meta data (functional): {if articles_seo_meta_data:total_rows > 0} {articles_seo_meta_data} {articles_seo_meta_data:...
user avatar
3 votes

displaying expired entries

To expound on my comment to this answer, and I acknowledge this is a bit unorthodox, this solution will improve performance by only executing one channel entries tag. The query tag will fetch the ...
user avatar
  • 2,255
3 votes

How do I check for an empty field in a child entry?

What version are you using? We fixed this problem in 2.9.3, though you can apply the solution if you'd rather not update. Open system/expressionengine/libraries/channel_entries_parser/Preparser.php ...
user avatar
  • 520
3 votes
Accepted

Wish a bit help with conditionals and operators

You've almost got it. {count} is the current count of the displayed entry in the tag's loop. Think of your entries as a numbered list, the {count} is the position in the list. {absolute_results} ...
user avatar
  • 2,255
3 votes

Conditional logic inside of <script> tags

OK, I feel like an idiot! Forgot about the Javascript template type. Solution: I simply created a new template, designated it as type "JavaScript", inserted my code, minus the <script> tags, ...
user avatar
3 votes
Accepted

How do I display alternative text when there are no active entries in a channel?

The reason your code is not working is because if ExpressionEngine does not return any results, then it doesn't even parse the tags - thus {total_entries} does not even exist in that context. Also ...
user avatar
3 votes

Need a Conditional for Tally

Looking at that plugin's code, it should work fine if you're using a tag pair, and its {tally_total} variable, e.g.: {exp:tally:total} {if ! tally_total}Your current total is 0.{/if} {/exp:tally:...
user avatar
  • 2,255
3 votes
Accepted

Problem with category conditional

If I'm not mistaken, for OR conditionals you must use one of the following: {if category_id != 305 OR category_id != 325} {if category_id != 305 || category_id != 325} also, please double check ...
user avatar
  • 589
3 votes

Why is the OR not working in a conditional statement?

You should try your code in below manner. {if ! 'portfolio|photos' *= segment_2} <h1>Conditional content.</h1> {/if} You can also try in another way also. {if segment_2 == '...
user avatar
3 votes
Accepted

Matching more than one segment

I would use this to check multiple pages: {if "page1|page2" *= segment_2} active {/if}
user avatar
3 votes
Accepted

Relationship Field Conditional Not Working

Although it is technically less efficient, you should try embedding it to render as a tag in the conditional like so: {if '{featured_movie:video_id}' != ''} Try that. As in the docs, if it isn't ...
user avatar
  • 5,900
2 votes
Accepted

Parent Relationship Conditional -- if not empty

you can use: {parents orderby="date" sort="desc" channel="articles" category="1" status="not closed"} {if parents:count == "1"}<h3>ARTICLES</h3>{/if} <h4><a href="{parents:...
user avatar
2 votes
Accepted

If custom channel field entry exists display content else display alternate content

Have you tried this? The difference is on Line 2. It does mean you're running the conditional against the entire embed string rather than the variable but it may work. {slider} {if "{video}"!=""} ...
user avatar
  • 1,449
2 votes

conditional based on what channel the entry selected in a playa field is in?

You can use {channel_short_name}: {if channel_short_name == "channel_a"} ... {if:else} ... {/if}
user avatar
2 votes

Advanced Conditions: {if:else} tag not getting read

As someone else has said this is an inelegant approach and there are better ways to do it. But for starters try putting the complete tag pair within each condition and see if that works. i.e. {...
user avatar
  • 7,176
2 votes

Advanced Conditions: {if:else} tag not getting read

Yikes! With all due respect, this is an extremely inelegant approach. You should never attempt to output different opening tags in this way. Even if you are able to somehow make it work, the next ...
user avatar
  • 4,885
2 votes
Accepted

Is still necessary using the Add-on Ifelse from Mark Croxton with EE2.9?

It depends. If you aren't using variables on conditional outside the default order, you can remove ifElse. For example, ifElse parses early variables like member_id and group_id. Take some time to ...
user avatar
  • 6,108
2 votes
Accepted

CartThrob {if error:your_field} conditional not working for item_options

I had a similar issue. Try adding quotes around the full tag so that you have: {if "{error:item_options[invoice_number]}"} Hopefully that should resolve it.
user avatar
  • 131
2 votes

Conditional based on file extension

change {if {extension} == 'jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF'} to {if section_1_files:extension== 'jpg' || section_1_files:extension=='JPG' ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible