PDA

View Full Version : Filter Problem


Varsh
07-14-2009, 08:45 PM
After using the filter with various criteria (I know it's not nested) I've come across a strange occurance. With each option list displayed the filter works fine but the problem doesn't come with the filtering but the labelling, instead of showing each label/title by the side of the options it only shows the last option title at the front of the filter set.

I've looked through the PHP file and noticed that the title setting is not within the loop for displaying the title by the options, any idea on how to do this?

Example: http://forums.nexusrealms.co.uk/forumdisplay.php?f=20

Morgan
07-14-2009, 09:56 PM
There is a how-to page here (http://www.thevbgeek.com/showthread.php?t=2582) with instructions for adding a filter, but you can use only one filter on the page. If you want to change this behavior, one place to start is to look at the prep_filter function in the gars_class_list.php page.

Varsh
07-14-2009, 10:20 PM
I think you've misunderstood what I'm asking. In fact let me show you what I mean. Currently I have this:

Title 5 - option list
option list
option list
option list
option list

I am wanting to achieve this:

Title 1 - option list
Title 2 - option list
Title 3 - option list
Title 4 - option list
Title 5 - option list

If I can find where the title is displayed in one of the files then I'll be able to edit it. Can you see what's happening though? All that is needed to be done is to display the title next to the option list when it is first selected before the records are added, I simply can't find this anywhere although the filter.php file seems to be the one to look at.

I get the feeling I need to place the following near where the option list is created but I'm struggling to find where you are echoing the options.
echo $result['typeid'];

Morgan
07-14-2009, 10:29 PM
Oh okay, that is in the filter.php file found inside the /geek/gars/mods/display directory. You might want to set $rowtitle to an array of titles instead of $rowtitle = $titles[$result['id']]; so then you could use the array variable with key name in the GARS_mod_filter template.

Varsh
07-14-2009, 11:47 PM
Thanks for the pointers, I've now managed to do a fix however it does remove the point of selecting whether it's a vertical or horizontal layout. There's two ways to do this:

Original
filter.php

$itemid = intval($itemid);
$autojs = " onchange=\"gars_filter_forum$itemid($result[id], this.value);\" ";
$optionlist = "<SELECT name=\"filter[$result[id]]\" $autojs >$optionlist</SELECT>";
}


Horizontal Layout
filter.php

$itemid = intval($itemid);
$autojs = " onchange=\"gars_filter_forum$itemid($result[id], this.value);\" ";
$optionlist = " | " . $titles[$result['id']] . " <SELECT name=\"filter[$result[id]]\" $autojs >$optionlist</SELECT> | ";
}


Vertical Layout
filter.php

$itemid = intval($itemid);
$autojs = " onchange=\"gars_filter_forum$itemid($result[id], this.value);\" ";
$optionlist = "<br />" . $titles[$result['id']] . "<SELECT name=\"filter[$result[id]]\" $autojs >$optionlist</SELECT>";
}


What needs to be known however is that in both instances vertical alignment must be set to "no". In the template GARS_mod_filter you need to do the following by removing $rowtitle:


<div class="smallfont" style="white-space:nowrap;">$rowtitle<if condition="$settings['vertical'] && $rowtitle"></div><else />&nbsp;</if>$bits<if condition="$settings['vertical']"></div><else />&nbsp;</if>


And change it to


<div class="smallfont" style="white-space:nowrap;"><if condition="$settings['vertical'] && $rowtitle"></div><else />&nbsp;</if>$bits<if condition="$settings['vertical']"></div><else />&nbsp;</if>


Another way around this is to create another template called GARS_mod_filter_V (vertical) and save the filter.php file as filterV.php (vertical) with the vertical settings so that you can set them to the modules like what is currently there. All you would need to do then is make sure to keep vertical alignment "off" for both of them and making sure that you use the right module where needed.

The horizontal layout needs some tweaking to look right, I'll most likely use CSS to distinguish between the options, though you can see how they separate from eachother now. Hope this helps. :)

You can now see it working here: http://forums.nexusrealms.co.uk/forumdisplay.php?f=20