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.

Where expression in template?

July 08, 2014 9:26am

Subscribe [2]
  • #1 / Jul 08, 2014 9:26am

    eigotec

    19 posts

    Hi,

    Continuing on with the student thing. I now need to have where statements in the template. For instance I want to find out if a student has 3 or more “A’s”. I know this can be done with the query plugin, but i’m using the url to get data per username, so i’m thinking that is no good?
    Can i use the count function to do this?

    Thanks.

  • #2 / Jul 08, 2014 10:09am

    eigotec

    19 posts

    Sorry, should read “Where conditional in template”

  • #3 / Jul 09, 2014 7:43am

    Boyink!

    5011 posts

    Have you reviewed the available parameters for the channel:entries tag?

  • #4 / Jul 09, 2014 10:05am

    eigotec

    19 posts

    Hi,

    Yeah i’ve reviewed the tags, but i was thinking i need a where clause?

    Sorry i’m very early in development with EE.

    Thanks.

  • #5 / Jul 09, 2014 10:21am

    Boyink!

    5011 posts

    You aren’t writing SQL. EE is taking your combination of EE tag pairs and parameters and writing that SQL for you.

    There is a parameter for the channel:entries tag pair that does effectively the same thing as a SQL where clause.

    Give the docs another look and if you don’t spot it I’ll link to it.

  • #6 / Jul 09, 2014 11:07am

    eigotec

    19 posts

    Ah so its the “search:field_name=” ? That looks interesting. Can i still get a count of the results returned from that though? Also sometimes i need to get a count and not display the result as a number.

    Thanks.

  • #7 / Jul 09, 2014 11:08am

    Boyink!

    5011 posts

    Try it…;)

  • #8 / Jul 09, 2014 12:50pm

    eigotec

    19 posts

    Ok that seems pretty straight forward, although its just returning all the results from the user.

    {exp:channel:entries channel="results" search:field_one="text" search:field_two="number"}
    
    <table>
     {results}
     <tr>
       <td>{results:date}</td>
       <td>{results:venue}</td>
       <td>{results:country}</td>
       <td>{results:session}</td>
       <td>{results:position}</td>
       <td>{results:fastest_lap}</td>
     </tr>
     
    
     {/results}
     
    </table>
    
    {/exp:channel:entries}

    Am i using the correct tags to return the results?

    Thanks.

  • #9 / Jul 09, 2014 1:34pm

    Boyink!

    5011 posts

    Are your fields literally named “field_one” and “field_two”?

    And are you searching for the literal strings of “text” and “number” ?

  • #10 / Jul 09, 2014 2:04pm

    eigotec

    19 posts

    Hi,

    Sorry no they’re just fillers. Field one is text and field two is a number.

  • #11 / Jul 10, 2014 7:47am

    Boyink!

    5011 posts

    I don’t understand why you are using fillers. You need to use actual field names and actual search strings that are in the content for it to work.

  • #12 / Jul 10, 2014 7:57am

    eigotec

    19 posts

    {exp:channel:entries channel="results" search:session="Race" search:position="01"}
    
    <table>
     {results}
     <tr>
       <td>{results:date}</td>
       <td>{results:venue}</td>
       <td>{results:country}</td>
       <td>{results:session}</td>
       <td>{results:position}</td>
       <td>{results:fastest_lap}</td>
     </tr>
     
    
     {/results}
     
    </table>
    
    {/exp:channel:entries}

    Sorry the fillers were just for this post. The above is the exact code i’m using.

  • #13 / Jul 11, 2014 4:41am

    eigotec

    19 posts

    Ok, on a brand new page, that seems to work fine. Not what i’ve done/haven’t done but its all good. Thanks for your help.

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

ExpressionEngine News!

#eecms, #events, #releases