1

I have a grid field type that is working correctly without any issuse. What i am trying to do is create an if statment basied on the search criteria of the grid search.

What I have:

<div class="twelve columns">
    {courses search:course_type="Foundation" search:degree_type="Masters" search:applies_to = "<?php echo $degreeName ?>"}
    <div class="more-button white course-list-title">
        {courses:course_number} {courses:course_title}
    </div>
    <div class="course-list-content">
        <p>{courses:course_content} </p>
    </div>
    {/courses}
</div>

The code above works fine. What I want to do is create an if statment basied on the number of rows, that only returns one thing regardless if there are rows or not.

Something like this:

{if courses:total_rows > 0 search:course_type="Foundation" search:degree_type="Masters" search:applies_to = "<?php echo $degreeName ?>" }
    Some Code
{if:else}
    Some Other Code
{/if}
1
  • What did you try?
    – Timo002
    Feb 19, 2014 at 22:53

1 Answer 1

1

You'll need to separate the conditional from the variable pair, as they parse as two completely different entities in EE. There's no way to combine them into one tag.

However, this is fairly simple to do. Try something like this.

{if courses:total_rows > 0 }
    {courses search:course_type="Foundation" search:degree_type="Masters" search:applies_to = "<?php echo $degreeName ?>" }
        Some Code
    {/courses}
{if:else}
    Some Other Code
{/if}
1
  • I have tried that. The problem is that the grid courses will always have rows in it. I want to check if there are rows in there after I have applied my filters Feb 20, 2014 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.