The WorksForWeb Community Forums
Welcome to the WorksForWeb community forums. Here you can discuss WorksForWeb products with others and contribute to the rapidly growing WorksForWeb community. Please note that while WorksForWeb staff try to maintain presence on the forums, this is not the most reliable way to contact WorksForWeb staff. In case you require a timely response from WorksForWeb on an issue, please open a support ticket here. For pre-sales questions, please open a sales ticket here.

Welcome, Guest. Please login or register.
May 23, 2012, 04:36:56 AM

Login with username, password and session length
Search:     Advanced search
Added the iLister-related Boards

Rate My Site Boards Added

Merged iAuto and iRealty Support Forums together

Several new tips in the Tips and Tricks section
1,604 Posts in 625 Topics by 1,179 Members
Latest Member: bobsteam
* Home Help Search Login Register
+  The iAuto/iRealty/iLister Support Forum
|-+  iAuto and iRealty v.2.x - 3.x
| |-+  General iAuto Discussions
| | |-+  change sorting field
« previous next »
Pages: [1] Print
Author Topic: change sorting field  (Read 1913 times)
RideTrader
Newbie
*

Karma: 0
Posts: 4


View Profile
« on: March 06, 2007, 10:18:54 AM »

I was trying to figure out how the  "quick" search form can be defaulted to
show results by Price/descending order.
Logged
autoguide
Newbie
*

Karma: 1
Posts: 10


View Profile
« Reply #1 on: March 10, 2007, 01:16:35 AM »

Hmm...great question we must be on the same wave pattern because I to am trying to change the default search display from "Ascending" to "Descending" because what I have done is added the "Featured" field to the "car display" form so I want the Featured results to show up first. This is completly separate from the "Featured_Block" which shows up at the top of all my pages.

I hope to hear a response about this too.

Thanks iAuto...
AG
Logged
MCBuyers
Newbie
*

Karma: 0
Posts: 6


View Profile
« Reply #2 on: March 11, 2007, 12:46:38 AM »

RideTrader: I'm pretty sure that you can use regular HTML to link to a specific ad in the database...
Have you tried to edit: {module name="classifieds" function="show_search_form" search_form="XX"} or {$MAIN_CONTENT}?
I don't where you can edit it or if it is even possible.

autoguide: where can you edit the "car display" form? how did you get the featured block to show up first on all your pages? also, can you share the URL to your website?

Thanks,
Sean
Logged
Smart Girl
Administrator
Full Member
*****

Karma: 5
Posts: 224


View Profile
« Reply #3 on: March 12, 2007, 01:53:34 PM »

Dear RideTrader and autoguide,

Unfortunately, you may not to assign the form to display the results by the default sorting order.

Only after the first search is done you may sort the results by certain field ascending or descending order. In order to do so, select the name of the field, select the ascending or descending order, and then click the "Go" button.
Logged

autoguide
Newbie
*

Karma: 1
Posts: 10


View Profile
« Reply #4 on: March 20, 2007, 01:22:23 AM »

I DID IT!!!

I am not an expert on script but I use Dreamweaver and keep a backup after FTP.
So please don't mess up your site....!!

Here is a good rule of thumb.
**BE CAREFUL IF YOU MODIFY PHP SCRIPT...ALWAYS KNOW WHAT YOUR DOING**

None the less here is what I did...to my site.
------------------------------------------------------------------------------------
I was able to change my sort function by modifiying my "db_search.php"

<script language="JavaScript">
function SetOrderBy (new_orderby) {
   sorting = document.forms.request_data.elements['sorting'];
   orderby = document.forms.request_data.elements['orderby'];
   current_orderby = orderby.value;
   if (new_orderby != current_orderby)
      sorting.value = 2;
   else {
      if (sorting.value == 2)
         sorting.value = 1;
      else
         sorting.value = 2;
   }
   orderby.value = new_orderby;
   document.forms.request_data.submit ();
}
</script>
<?php
if(!isset($_REQUEST['orderby']))
   $_REQUEST['orderby']='';
if(!isset($_REQUEST['sorting']))
   $_REQUEST['sorting']=2;
if($_REQUEST['sorting']!=1)
   $_REQUEST['sorting']=2;

function order_window ($arr) {
   $result = '<table cellspacing=0 cellpadding=0 style="padding-left:5">'
      .'<tr><td>'.SORT_BY.'</td><td align="right">&nbsp;<select name="orderby" class="list" style="width:150">';
   foreach ($arr as $k => $v)
      $result .= '<option value="'.htmlspecialchars($k).'"'.($k == $_REQUEST['orderby']?' selected':'').'>'
         .htmlspecialchars($v).'</option>';
   $result .= '</select>'
      .'</td><td align="right">&nbsp;<select name="sorting" class="list" style="width:100"><option value=1>'.DESC.'</option>';
   if($_REQUEST['sorting']==2)
      $result.='<option value=2 SELECTED>'.ASC.'</option>';
   else
      $result.='<option value=2>'.ASC.'</option>';
   $result.='</select></nobr></td></tr></table>';
   return $result;
}
------------------------------------------------------------------------------------
The Car Display form I changed was "featured_block.html"
------------------------------------------------------------------------------------
For my "index page" I edited the html for {module name="classifieds" function="featured_listings_block" featured_number_x="4" featured_number_y="1"} to appear at the top.
------------------------------------------------------------------------------------
For my "main page" I left the {main_content} tag alone which shows the Featured Cars for the "main page" only.
------------------------------------------------------------------------------------

I also modified my "search_result_block.tpl" to include the and added a new "SetOrderBy" Field...it coresponds to a "Field Number" in your database. In this case the sort field is 22.

   <td>
   <a href="#" onclick="SetOrderBy (22); return false">Featured[/url]
   {if $orderby eq 22}
      {if $sorting eq 1}
         &uarr;
      {else}
         &darr;
      {/if}
   {/if}
   </td>

------------------------------------------------------------------------------------
Actually, I really haven't modified any {main_content}
------------------------------------------------------------------------------------
Again I assume no resposibility if your site skips a beat but here is my site if you want to check it out!

www.searchautoguide.com

It has only 5 cars in it now but I plan on populating it with about 1000 by next week.
Logged
BrandFly
Newbie
*

Karma: 0
Posts: 16


View Profile
« Reply #5 on: July 25, 2007, 03:30:20 AM »

There's got to be an easier way to just change the default sorting order of the price. All I want to do is make it so that the highest price shows first (price descending). What should I edit in the db_search.php file? To do this, here's what I changed (I'm not 100% sure what all this affects, but it worked in this case)

In the db_search.php, change this (about line 18):

<?php
if(!isset($_REQUEST['orderby']))
   $_REQUEST['orderby']='';
if(!isset($_REQUEST['sorting']))
   $_REQUEST['sorting']=1;
if($_REQUEST['sorting']!=2)
   $_REQUEST['sorting']=1;

to:

<?php
if(!isset($_REQUEST['orderby']))
   $_REQUEST['orderby']='';
if(!isset($_REQUEST['sorting']))
   $_REQUEST['sorting']=2;
if($_REQUEST['sorting']!=1)
   $_REQUEST['sorting']=2;

All I did is swap the numbers. If anybody has more detailed insight as to what this does then let me know.
« Last Edit: July 25, 2007, 03:38:11 AM by BrandFly » Logged

Dustin | BrandFly

iRealty V3.4
http://www.brandfly.com
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Classified Software by Worksforweb Powered by SMF 1.1.8 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!