Webmastersite.net
Register Log In

multi selection check boxes and filters

Comments on multi selection check boxes and filters

mrowton
Forum Regular

Usergroup: Customer
Joined: Feb 19, 2004
Location: Michigan

Total Topics: 57
Total Comments: 185
mrowton
Posted Mar 09, 2006 - 10:22 AM:

Using filters on link fields entered through a drop down selecter works fine.

I have a link field that uses a text boxes to select multiple attributes and cant seem to get it to work.

I have the following attributes

red, blue, green

If I edit a link and check all three then it wont display this link when I filter to green links only.

If I edit the link and check only the green box then it still wont display this link with I filter to green links only.

I'm using the same syntax on my filter form as my other filter post

Some of the options do contain spaces and /'s. Could this be a problem?
mrowton
Forum Regular

Usergroup: Customer
Joined: Feb 19, 2004
Location: Michigan

Total Topics: 57
Total Comments: 185
mrowton
Posted Mar 10, 2006 - 8:07 AM:

Update:

I can't get the filter to work with check boxes or multi selection cobo boxes. It looks like any text field that has an option can't be sorted.

Filtering will be very important to this new site in development and i'm hesitant to continue without having some kind of solution. Perhaps some kind of custom search string that presents the user with the correct links would work better.

It would be great if you could shine some light on this Paul, can you reproduce?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Mar 12, 2006 - 5:05 PM:

From the manual:
For text fields it will filter to where the value is exactly the same.


Which probably isn't very useful to you if you have a field which contains Red|Green|Blue since its value is not equal to any of Red, Green or Blue.

I suppose a feature could be added for 'contains' filters. In start.php,
  	 if (!strstr($value, "'")) $settings->condition .= " ". $field ." = '". $value ."' AND";
else $settings->condition .= ' '. $field .' = '. $value .' AND';
becomes
         if ($filtertype == 'contains') $settings->condition .= " ". $field ." LIKE '%". $value ."%' AND";
else
{
if (!strstr($value, "'")) $settings->condition .= " ". $field ." = '". $value ."' AND";
else $settings->condition .= ' '. $field .' = '. $value .' AND';
}
(now documented)
mrowton
Forum Regular

Usergroup: Customer
Joined: Feb 19, 2004
Location: Michigan

Total Topics: 57
Total Comments: 185
mrowton
Posted Mar 13, 2006 - 8:34 AM:

Works great, note to people who read this in the future, you need to add &filtertype=contains to the form action.

If I ever see you on the street I'll kiss you. (that is a complement, not a threat)

Now I'm gonna go try and use a multi selection form of some kind to let viewers select any of the colors they want to see instead of a single color.

mrowton
Forum Regular

Usergroup: Customer
Joined: Feb 19, 2004
Location: Michigan

Total Topics: 57
Total Comments: 185
mrowton
Posted Mar 13, 2006 - 9:52 AM:

Some links can have multiple colors. I wan't users to be able to filter by multiple colors and have any link containing any of those colors to show up.

I can't seem to get this to work. The below works fine if you select any single color. But if you select more than one, it only applies the first choice.

I was looking around some other templates where you have used multi selection forms and see that there are [] and [123] placed in some places. I've tried randomly adding these at different places in the form.
<form action="index.php?action=displaycat&catid={CATID}&filter=color&linkfilteraction=add&filtertype=contains" method="post"> 
<select multiple name="filtervalue">
<option value="removefilter">Any Color</option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Brown">Brown</option>
</select>
<input type="submit" value="Filter">
</form>

Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Mar 15, 2006 - 11:11 AM:

There is no multiselection option for filters. If there were, you'd have to make it an array, name=filtervalue[]... but there's no code to handle the array anyway so it wouldn't know what it was supposed to do with the values.

If you can check how the data is stored in the database -- is the 'color' field containing |blue|red| like I'm guessing, or blue,red, or some other sort of separator? -- that would speed the possibility of adding such an option.
mrowton
Forum Regular

Usergroup: Customer
Joined: Feb 19, 2004
Location: Michigan

Total Topics: 57
Total Comments: 185
mrowton
Posted Mar 15, 2006 - 3:46 PM:

Blue, Red, Green

No hurry, it looks like it may be better to go back to using a search string anyhow, these seem to be a little easier for me.

The fact that the filter is kept in your cookie (im guessing) keeps messing me up because I forget that I set it and then wonder where all the links went later on.

What about a &filtertype=not, I could see that being useful

The site is actually online now, you can see how Im using the filters here

Id like to let people choose to see the links in that category where the license type is either (GNU GPL, Freeware, etc..) But as an alternative a "not" filter could show all licenses that aren't "commercial"

Im going to add some really cool search functions on the front page next...

here is a details page that lets you see how im using all these new link and rating fields. Its all integrated into WSN Forums.

Would have costs several thousands to do this from scratch. Still a few template changes that need to be made but its getting there.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7867
Paul
Posted Mar 16, 2006 - 10:14 AM:

Multiselect should work in 3.3.10, but is untested. Same goes for 'not'.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.