You are on the same track to the solution as i'm using it on my fashion sites. I will try to depict it step by step:
Import
For me ( and probably for you in the future as well ) it's important to have the sizes delimited by a ',' on both sides
size like '%,1' would match ',1' but also ',10'
the following code example shows a solution, it also shows a solution for '|' delimited sizes.
this goes into your feeds.php import filters.
Code:
function sizes_cb(&$item) {
generic_cb($item);
sizes($item);
}
function sizes_pipe_cb(&$item) {
generic_cb($item);
$item['menu_12']=explode('|',$item['menu_12']);
sizes($item);
}
function sizes(&$item) {
if ( ! is_array($item['menu_12']) ) {
$m12=explode(',',$item['menu_12']);
} else {
$m12=$item['menu_12'];
}
asort($m12);
#todo trim() each element and ommit empty ones
$item['menu_12']=','.join(',',$m12).',';
}
Queries
if you put your version of the db_select function into components/com_datafeeds/helpers/xhelpers.php i will be preserved whenever you update the component.
Code:
if ( $f == 'Select12' ) {
if ($not === false ) {
return '`Select12` like ' . $db->Quote("%,$t,%");
} else {
return '`Select12` != \'\'';
}
} else {
#existing code
}
the return for the 'not' situation might seem odd, your solution will not work. And
Select12 not like '%,$t,%' would neither. Consider a $t='8' and a sizes string like 6,7,8,9. Result sizes 6,7,9 are not shown.
display
quite right about the sorting and uniques and other issue with large arrays. What I do is loop thru the sizes, explode each, create a new array with those. below a diff for the existing default.php
Code:
--- default.php (revision 2123)
+++ default.php (working copy)
@@ -25,6 +25,25 @@
$baselink .="&q$v=".urlencode($x);
}
}
+ $sizelevel='2';
+ if ( $dataitems['level'.$sizelevel]) {
+ foreach ($dataitems['level'.$sizelevel] as $v ) {
+ foreach (explode(',',$v) as $w ) {
+ @$new[trim($w)]++; # should be done during import
+ }
+ }
+ unset ( $dataitems['level'.$sizelevel] ) ;
+ unset ($new[strtolower(${'q'.$sizelevel})]); # THIS IS THE MISSING NOT FROM THE QUERY
+ unset ($new['']); #fail save,
+ ksort($new);
+ # if you don't care about the uppper is array_keys,
+ # or if you like fancy functions use array walk after array_keys
+ foreach ( $new as $k => $v ) {
+ $k=strtoupper($k);
+ $dataitems['level'.$sizelevel][]=$k;
+ }
+ }
+
print '<div id="'.$mod_div.'" class="menu'.$params->get('moduleclass_sfx').'">';
$verwijder=$params->get('removestring',"Verwijder");
for ($v=$start;$v<=$stop;$v++) {
I did quite some benchmarking in the past, using function like array_walk to do the strtouper didn't make much of a difference.