PDA

View Full Version : Very Fast Min Max Box



greengiant
09-02-2003, 08:41 AM
Hi,

Well i have found one solution to out slow build time for the min max search boxes. It involves the use of a commerical java applet. Pull Down Menu (apChoiceMenu). Which there is a demo avalialbe for downloadhere. http://www.apycom.com/pull-down-menu/index.html. It only cost like $15, well worth the speed increase.... If anyone knows of any gpl java applets that will do what this applet wil let me know, and i will incorporate it into the next release.. In the mean time. You need to download/purchase the apChoiceMenu then replace your listing_browse.php page and your style.php page with the ones in this zip.

http://www.open-realty.org/release/java-minmax.zip (THIS DOES NOT INCLUDE THE JAVA APPLET)


Here are the actual chages to the two files, for thoose that have modified the origional files.

listing_browse.php Line 257


$col = strtok($ElementIndexValue, '_');


style.php replace the existing searchbox_minmax function with this one.


function searchbox_minmax ($browse_caption, $browse_field_name, $rental = "no")
{
$minmax_start_time = getmicrotime();
// builds a min/max combo box
// to let users search by
global $conn, $config, $lang;
echo '<tr><td align="right"><b>'.$browse_caption.'</b> ';
echo '</td><td align="left">';
$sql = "SELECT field_type, search_step FROM " . $config&#91;'table_prefix'&#93; . "listingsFormElements WHERE field_name = '$browse_field_name'";
$rsStepLookup = $conn->Execute&#40;$sql&#41;;
if &#40;$rsStepLookup === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
// Get max, min and step
$step = $rsStepLookup->fields&#91;'search_step'&#93;;
$field_type = $rsStepLookup->fields&#91;'field_type'&#93;;
if &#40;$field_type == 'price'&#41;
&#123;
$price = True;
&#125;
else
&#123;
$price = False;
&#125;
$sql = "SELECT listing_id FROM " . $config&#91;table_prefix&#93; . "listingsDBElements WHERE field_name = 'type' AND field_value <> '".$lang&#91;rental&#93;."'";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41;
&#123;
log_error&#40;$sql&#41;;
&#125;
$rental_str = ' AND ' . $config&#91;'table_prefix'&#93; . 'listingsDB.ID IN &#40;';
$count = 0;

while &#40;!$recordSet->EOF&#41;
&#123;
if &#40;$count != 0&#41;
$rental_str .= ', ';
$rental_str .= $recordSet->fields&#91;listing_id&#93;;
$recordSet->MoveNext&#40;&#41;;
$count++;
&#125;
$rental_str .= '&#41; ';
$max = $conn->GetOne&#40;"select min&#40;field_value +0&#41; from " . $config&#91;table_prefix&#93; . "listingsDBElements, " . $config&#91;table_prefix&#93; . "listingsDB where field_name = '$browse_field_name'".$rental_str&#41;;
if &#40;$price == True&#41;
&#123;
$min = round&#40;$conn->GetOne&#40;"select max&#40;field_value +0&#41; from " . $config&#91;table_prefix&#93; . "listingsDBElements, " . $config&#91;table_prefix&#93; . "listingsDB where field_name = '$browse_field_name'".$rental_str&#41;, -3&#41;;
&#125;
else
&#123;
$min = $conn->GetOne&#40;"select max&#40;field_value +0&#41; from " . $config&#91;table_prefix&#93; . "listingsDBElements, " . $config&#91;table_prefix&#93; . "listingsDB where field_name = '$browse_field_name'".$rental_str&#41;;
&#125;
if &#40;$min > $max&#41;
&#123;
$temp = $min;
$min = $max;
$max = $temp;
&#125;
?>
<input type="hidden" name="<?php echo $browse_field_name; ?>_min">
<input type="hidden" name="<?php echo $browse_field_name; ?>_max">
<script language="JavaScript" type="text/javascript">
<!--
<?php
echo 'function '.$browse_field_name.'_min &#40; minvalue &#41;';
echo '&#123;';
echo 'document.listingsearch.'.$browse_field_name.'_min .value = minvalue ;';
//echo 'document.listingsearch.'.$browse_field_name.'_min .submit&#40;&#41; ;';
?>
&#125;
-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
<?php
echo 'function '.$browse_field_name.'_max &#40; maxvalue &#41;';
echo '&#123;';
echo 'document.listingsearch.'.$browse_field_name.'_max .value = maxvalue ;';
//echo 'document.listingsearch.'.$browse_field_name.'_max .submit&#40;&#41; ;';
?>
&#125;
-->
</script>
<?php
echo 'from ';
?>
<!--Start Min Java Box-->
<applet Code=apChoiceMenu.class Width=100 Height=18 mayscript>
<param name=Copyright value=Apycom.com><a href="http&#58;//www.apycom.com">&#40;c&#41; Apycom</a>
<param name="delimiter" value="~">
<param name="backColor" value="cceecc">
<param name="menuColor" value="cceecc">
<param name="fontColor" value="0000ff">
<param name="font" value="Arial,10,1">
<param name="menuItems" value="
<?php
$options = "&#123; ~javascript&#58;".$browse_field_name."_min&#40;''&#41;~_&#125;";
$options2 = "&#123; ~javascript&#58;".$browse_field_name."_max&#40;''&#41;~_&#125;";
if &#40;$price == True&#41;
&#123;
for &#40;$i = $min; $i <= $max; $i += $step&#41;
&#123;
$z = international_num_format&#40;$i&#41;;
$z = money_formats&#40;$z&#41;;
$options .= "&#123;".$z."~javascript&#58;".$browse_field_name."_min&#40;'$i'&#41;~_&#125;";
$options2 .= "&#123;".$z."~javascript&#58;".$browse_field_name."_max&#40;'$i'&#41;~_&#125;";
if &#40;$i - $step > $max&#41;
&#123;
$i = $max;
$options .= "&#123;".$z."~javascript&#58;".$browse_field_name."_min&#40;'$i'&#41;~_&#125;";
$options2 .= "&#123;".$z."~javascript&#58;".$browse_field_name."_max&#40;'$i'&#41;~_&#125;";
&#125;
&#125;
&#125;
else
&#123;
for &#40;$i = $min; $i <= $max; $i += $step&#41;
&#123;
$options .= "&#123;".$i."~javascript&#58;".$browse_field_name."_min&#40;'$i'&#41;~_&#125;";
$options2 .= "&#123;".$i."~javascript&#58;".$browse_field_name."_max&#40;'$i'&#41;~_&#125;";
if &#40;$i - $step > $max&#41;
&#123;
$i = $max;
$options .= "&#123;".$i."~javascript&#58;".$browse_field_name."_min&#40;'$i'&#41;~_&#125;";
$options2 .= "&#123;".$i."~javascript&#58;".$browse_field_name."_max&#40;'$i'&#41;~_&#125;";
&#125;
&#125;
&#125;
echo $options;
echo '"></applet>';
// Start Max Button
echo ' to ';
?>
<!--Start Max Java Box-->
<applet Code=apChoiceMenu.class Width=100 Height=18 mayscript>
<param name=Copyright value=Apycom.com><a href"=http&#58;//www.apycom.com">&#40;c&#41; Apycom</a>
<param name="delimiter" value="~">
<param name="backColor" value="cceecc">
<param name="menuColor" value="cceecc">
<param name="fontColor" value="0000ff">
<param name="font" value="Arial,10,1">
<param name="menuItems" value="
<?php
echo $options2;
echo '"></applet>';
echo '</td></tr>';
&#125; // end function
[/url]

marb
09-02-2003, 12:36 PM
perhaps is this somehing;
http://www.codelifter.com/main/javascript/dropdown.shtml

met vriendelijke groet,
marten :)

greengiant
09-02-2003, 12:52 PM
Nope that is a javascript dropdown, i want a java applet. The javascript from what i have read will be just a tad slower then the html dropdown..

marb
09-02-2003, 01:54 PM
sorrrrriiiieeee
my fold dont read good
perhaps this is better;

http://biphome.spray.se/kongas/Linklister.html
http://www.geocities.com/zmei666/popupmenu.html
http://www.jpowered.com/menu/index.htm
http://www.codebrain.com/java/ipopper/index.html
http://www.lordmark.de/SB/
http://www.dynamicdrive.com/dynamicindex1/index.html

marten :)

Andre
09-02-2003, 04:04 PM
I would be careful about using applets. If the users browser isn't configured correctly, the applet will not load. I couldn't get an applet to load on a PC I was using until I downloaded the latest plug-ins from java.sun.com. I knew what to do, but will your average user know?

Andre
09-02-2003, 04:11 PM
I'm not using your version, but if you'll post the code used for the min-max price, I'll be glad to take a look at it to see if I could come up with something.

Anonymous
03-01-2004, 07:42 AM
I would be careful about using applets. If the users browser isn't configured correctly, the applet will not load. I couldn't get an applet to load on a PC I was using until I downloaded the latest plug-ins from java.sun.com. I knew what to do, but will your average user know?

I would concur most strongly with that

gwmbox
03-01-2004, 11:23 PM
me too! - stay right away from applets, even javascript if possible as many users have it turned off - so it would be useless anyway. I'd rather have it load slower than have an applet.

I'm all for a 100% java (anything) free OR

My 2 cents worth :)

Greg

gwmbox
03-01-2004, 11:24 PM
me too! - stay right away from applets, even javascript if possible as many users have it turned off - so it would be useless anyway. I'd rather have it load slower than have an applet.

I'm all for a 100% java (anything) free OR - i.e. no java in it at all.

My 2 cents worth :)

Greg

laurenced
02-17-2005, 03:53 PM
I got round ultra slow min max boxes by allowing the user to input their own range. That way, my search page wasn't loading 9400 (yes, 9400) drop down box options!

Laurence

frobn
02-17-2005, 05:03 PM
I got round ultra slow min max boxes by allowing the user to input their own range. That way, my search page wasn't loading 9400 (yes, 9400) drop down box options!

Laurence

I don't see a selection in the template to allow that type of search. Did you hard code the min/max option?