Hi David,
I use sizes as filter, but sometimes the sizes comes like:
39,40,41,43,45
and the next product:
38,40,41,43,46
Is it possible to make this in one row? like:
38
39
40
41
43
45
46
Thx
Henk
Hi David,
I think this I must changing this in pto_search.php, but nothing changed my filter:
maat=size
this one gives an idea:
{link saved}
Thx
Henk
Hi Henk,
That should do it - e.g.
if ($pto_filter == "maat")
{
$allSizes = array();
for($i=0;$i<$numRows;$i++)
{
$sizes = explode(",",$wpdb->last_result[$i]->maat);
foreach($sizes as $size) $allSizes[$size] = 1;
}
ksort($allSizes);
$wpdb->last_result = array();
foreach($allSizes as $size => $v)
{
$wpdb->last_result[] = (object)array("maat"=>$size);
}
$numRows = count($wpdb->last_result);
}
for($i=0;$i<$numRows;$i++)
Cheers,
David.
--
PriceTapestry.com
Looks good!!!!
There are some double rows;
33
33
34
35
36
37
37
And is it possible to make it numeric alphabetical.
Thx
Henk
Hello Henk,
That's most likely a trim() required on the values (some having spaces, others not). Using SORT_STRING should give numeric first, alphanumeric second... Have a go with:
if ($pto_filter == "maat")
{
$allSizes = array();
for($i=0;$i<$numRows;$i++)
{
$sizes = explode(",",$wpdb->last_result[$i]->maat);
foreach($sizes as $size) $allSizes[trim($size)] = 1;
}
ksort($allSizes,SORT_STRING);
$wpdb->last_result = array();
foreach($allSizes as $size => $v)
{
$wpdb->last_result[] = (object)array("maat"=>$size);
}
$numRows = count($wpdb->last_result);
}
for($i=0;$i<$numRows;$i++)
Cheers,
David.
--
PriceTapestry.com
Hi Henk,
Sure - first you'd need to change the $priceWhere construction so that the size filter is applied using LIKE rather than EQUALS. To do this, in your modified pto_product.php where you currently have at line 164:
if ($$fn) $priceWhere .= " AND ".$pto_filter." = '".$wpdb->escape($$fn)."' ";
...REPLACE this with:
if ($pto_filter=="size")
{
if ($$fn) $priceWhere .= " AND size LIKE '%".$wpdb->escape($$fn)."%' ";
}
else
{
if ($$fn) $priceWhere .= " AND ".$pto_filter." = '".$wpdb->escape($$fn)."' ";
}
Since you're using "generic" code to create each filter, the easiest way to "rewrite" the options array is to re-create the $wpdb->last_result array. To do this, look for the following code at line 1018:
for($i=0;$i<$numRows;$i++)
...and REPLACE with:
if ($pto_filter == "size")
{
$allSizes = array();
for($i=0;$i<$numRows;$i++)
{
$sizes = explode(",",$wpdb->last_result[$i]->size);
foreach($sizes as $size) $allSizes[$size] = 1;
}
ksort($allSizes);
$wpdb->last_result = array();
foreach($allSizes as $size => $v)
{
$wpdb->last_result[] = (object)array("size"=>$size);
}
$numRows = count($wpdb->last_result);
}
for($i=0;$i<$numRows;$i++)
...should be close!
Cheers,
David.
--
PriceTapestry.com