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.

Conditional

November 29, 2011 7:55am

Subscribe [2]
  • #16 / Jan 18, 2012 12:13pm

    Hi Matt. Thanks again for getting back to me.

    I have limited it down to just one segment of the conditional to test.

    If I move the conditional outside of the exp:channel:entries tag pair, then it cant see any results.

    Yes, headache is right! I don’t seem to be getting anywhere here.

    Is there anyway you can think of doing this without using the conditionals?

  • #17 / Jan 18, 2012 3:35pm

    Matt Powell

    42 posts

    Can you post the latest version of the code with the simplified conditional?

  • #18 / Jan 19, 2012 2:57am

    Here is the simplified code, with the channel entry tags outside of the conditional.

    <ul>
    
    {if segment_2 == "" XOR (segment_2 == "africa" AND continent == "africa")}
    
    {exp:channel:entries channel="tours" limit="10" orderby="date" sort="asc" dynamic="no"}
    
    {tour_date}
    
        <li>
    
        {title} - {tour_price}
    
        </li>
    
    {/tour_date}
    
    {/exp:channel:entries}
    
    {if:else}
    No
    {/if}
    
    </ul>

    With this code, the if else statement returns a message. If I use no_result it doesn’t return anything. However, this code returns no tours even if tours are selected as ‘africa’, thus it doesn’t work.

    Thanks

  • #19 / Jan 19, 2012 3:34am

    Matt Powell

    42 posts

    hi again

    the first bit won’t work

    {if segment_2 == "" XOR (segment_2 == "africa" AND continent == "africa")}

    checking for the continent variable outside of the exp:channel query won’t work. you’ll need to check the segment outside and check the continent inside, if that makes sense!

  • #20 / Jan 19, 2012 3:35am

    Matt Powell

    42 posts

    i think you’re also missing an end to one of your ifs.

  • #21 / Jan 19, 2012 3:37am

    Again thanks for getting back to me.

    Hmm, how would I check outside and inside? Could you give me an example?

    I have checked the code, I only have one open if, if:else and close if. Where is the missing close if?

    Thanks

  • #22 / Jan 19, 2012 4:10am

    Matt Powell

    42 posts

    sorry my bad re. the if.

    try something like this - note i haven’t used the search: parameter before but should be something like this

    <ul>

    {if segment_2 == "africa"}

    {exp:channel:entries channel="tours" limit="10" orderby="date" sort="asc" dynamic="no" search:continent="=africa"}

      {tour_date}

        <li>{title} - {tour_price}</li>

      {/tour_date}

    {/exp:channel:entries}

    {if:else}

    Not africa

    {/if}

    </ul>

  • #23 / Jan 19, 2012 4:12am

    Matt Powell

    42 posts

  • #24 / Jan 19, 2012 4:18am

    Thanks Matt.

    This works for this single variable. But how could I get this to work with all the different refining options I need? Also, this only appears to work with textarea, text input and dropdown fields. I am using a matrix field for dates.

    Any ideas?

  • #25 / Jan 19, 2012 4:23am

    Matt Powell

    42 posts

    may i ask why you’re using matrix fields for dates?

  • #26 / Jan 19, 2012 4:23am

    Matt Powell

    42 posts

    and i can’t see any reference to dates in your original post…

  • #27 / Jan 19, 2012 4:25am

    Matt Powell

    42 posts

    sorry was being a div.

    i think it’s the ‘search:continent” which only works with those type of fields. you should be able to use any type of field in the output

    From the user guide - “Note: Only fields of the type “Text Input”, “Textarea”, and “Drop-down Lists” are searched with this parameter.”

  • #28 / Jan 19, 2012 4:45am

    I removed all the conditionals but one to simplify it.

    I will be looking to refine by, continent, month/year, price and fitness.

    I am using Cart Throb with Matrix. I need to specify a start, and end date for each tour, so am using a matrix field with a fieldtype of ‘dropdate’.

    I have just tried using the search option to look in the matrix field and there are no results and no message.

    I tried this: search:tour_date=”{segment_2}”

  • #29 / Jan 19, 2012 5:00am

    I have found an equivalent for Matrix so it works.

    <ul>
    
    {if segment_2 == "2012"}
    
    {exp:channel:entries channel="tours" limit="10" orderby="date" sort="asc" dynamic="no"}
    
    {tour_date search:option_value="2012"}
        
        <li>
        {title} - {tour_price}
     </li>
    
      {/tour_date}
    
    {/exp:channel:entries}
    
    {if:else}
    
    Not africa
    
    {/if}
    
    </ul>

    I am not quite sure how I can use conditions to execute all the different refining options though. How can I get multiple conditionals in this?

    Thank you

     

  • #30 / Jan 19, 2012 5:03am

    Matt Powell

    42 posts

    doesn’t look like you can use variables in the search: parameter so this won’t work

    search:tour_date=”{segment_2}”

    so we need to think again.

    have you looked at custom queries at all? it looks to me like a sql query might be your best bet. complicated though!

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

ExpressionEngine News!

#eecms, #events, #releases