We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47188
    • 4 Posts
    Ok, before anyone points me to RTFM, let me just say, that I've actually implemented this on a few sites, using getpage rather than just getresources and they have all worked according to my needs, and what those needs were was to give visitors the ability to sort a list according to a template variable.

    Now in all instances I used a listbox (single select)template variable as so (in this case for rating):

    1==[[$one_star]] || 1.5==[[$one_and_half]] || 2==[[$two_star]] || 2.5==[[$two_and_half]] || 3==[[$three_star]] || 3.5==[[$three_and_half]] || 4==[[$four_star]] || 4.5==[[$four_and_half]] || 5==[[$five_star]]


    Now, on my current project which is days from launch, I created a template variable called "price", in which the numerical value is entered into a text field, nothing more and, for some reason, getpage doesn't return the proper output. For example on a "low to high" page the first in the list is not the lowest priced item.

    here's an example of the call. (I use getpage for pagination)

    [[!getPage? &elementClass=`modSnippet` &showHidden=`1` &sortbyTV=`price` &sortdirTV=`ASC` &element=`getResources` &parents=`7,8,9,10,11,12` &limit=`8` &pageLimit=`2` &pageVarKey=`page` &includeTVs=`1` &includeContent=`1` &tpl=`store_post` &tvPrefix=`tv.` &cache=`0`]]
    <div class="paging">
    <ul class="pageList">
      [[!+page.nav]]
    </ul>
    </div>


    and here's the template:

     
     <div class="product_info_container">
          
          <div class="product_name">[[+tv.product_name]]</div>
          <div class="product_details">[[+tv.product_details]]</div>
          <div class="product_price">price: [[+tv.price]] USD</div>
          <div class="product_purchase">[[+tv.pay_button]]</div>
          <div class="view_cart">[[$viewcart]]</div>
          
    </div>
    


    I'm on Revolution 2.2.13-pl (I tried updating to 2.2.14 but there was a php error which scared the begeezus outta me and until I isolate the cause, with launch looming, I'm not touching it! tongue) All packages are current as well.

    Any help or suggestions would be greatly appreciated smiley

    p.s. I know the above getpage call is for ASC not DESC...I was just using the low to high as an example [ed. note: tux384 last edited this post 12 years, 6 months ago.]
      • 47188
      • 4 Posts
      Bump, ok, here's what's going on, I've figured out that sorting won't work on the entire numeric value,but rather just compare the first digit, then the next.
      for example if I set it high to low and write in the template variable:

      1.00
      2.00
      3.00
      4.00


      it will output:

      4.00
      3.00
      2.00
      1.00


      that's great, but if I write:

      17.00 
      169.00
      19.00 



      it will output:

      19.00
      17.00
      169.00


      Any ideas how this can be fixed? This is a feature which would go a long way on an online store, real estate site, etc. Do I need to post to github or something or is there a way to make it sort correctly?