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.

Ordering table of search results from grid with relationship

October 26, 2014 7:36am

Subscribe [2]
  • #1 / Oct 26, 2014 7:36am

    eigotec

    19 posts

    Hi,

    I have this page: http://proracedriver.com/drivers/leaderboard. I want the table to be in order of the total on the far right-hand-site.

    <td>
       {relationship}
        {if '{relationship:results_grid:total_rows search:session="Race" sort="desc"}' >= 10 && '{relationship:results_grid:total_rows search:session="Race" sort="desc"}' <= 24}      <div class="badgeHolder"  background: url('/images/badges/100/bronze.png') no-repeat;" width="100" height="100" class="badgeSmall img-responsive">
          <div class="totalRows">{relationship:results_grid:total_rows search:session="Race" sort="desc"}</div>
         </div>
        {if:elseif '{relationship:results_grid:total_rows search:session="Race"}' >= 25 && '{relationship:results_grid:total_rows search:session="Race"}' <= 49}      <div class="badgeHolder"  background: url('/images/badges/100/silver.png') no-repeat;" width="100" height="100" class="badgeSmall img-responsive">
          <div class="totalRows">{relationship:results_grid:total_rows search:session="Race" sort="desc"}</div>
         </div>
        {if:elseif '{relationship:results_grid:total_rows search:session="Race"}' >= 50}
         <div class="badgeHolder" background: url('/images/badges/100/gold.png') no-repeat;" width="100" height="100" class="badgeSmall img-responsive">
          <div class="totalRows">{relationship:results_grid:total_rows search:session="Race" sort="desc"}</div>
         </div>
        {if:else}
         <div class="badgeHolder" background: url('/images/badges/100/locked.png') no-repeat;"  width="100" height="100" class="badgeSmall img-responsive">
          <div class="totalRows">{relationship:results_grid:total_rows search:session="Race" sort="desc"}</div>
         </div>
    
        {/if}
       </div>
       {/relationship}
      </td>

    The above code is code i’m using to display the count of races a driver has competed in. Can I sort this with the native EE? I’d rather not go down the JS or db query route. Thanks.

  • #2 / Oct 27, 2014 12:34pm

    Giraffentoast

    152 posts

    Seems like you decided to go for a JS solution in the end? Which is sad, because this is absolutely not JS business plus you now got a web site that even stops working w/o JS.

    Is there a reason you got drivers and races separated? If you joined them, you could just order by that field.

    For best results, you should definitely write your own database queries for data heavy pages like that one. Or ask someone to do it for you (mySQL, I guess). It will pay off in flexibility and speed. This is not something you wanna do with template tags.

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

ExpressionEngine News!

#eecms, #events, #releases