List Filters

winchester

Member
Ok. this might be a tricky one.

I have radiobutton elements that has multiple options to "Yes" (see example below). On the list filter, though, rather than listing all the radiobutton options, I'd like a single check boxes which will filter ALL the "Yes".

fabrik-filter-01.JPG

basically, I just want a single checkbox with "Parking" as the label so that when selected, it will show ALL entries with "parking", regardless of how many cars the parking area can hold.

Is there a way to do this?

Thanks,
Winchester
 
Hmm.

The only way round that I could think of would be to use another, hidden, element. Maybe a yesno element. And have a simple PHP form submission plugin script which sets it according to the main parking radio ... so something like this, running 'onBeforeProcess', front and back end, edit and new ...

Code:
// change 'yourtable___parking' to the full element name of your main radio
$parking = $formModel->getElementData('yourtable___parking', true);
$parking = is_array($parking) : $parking[0] : $parking;

// replace '0' with whatever the radio option value for "No Parking" is
if ($parking === '0') {
   $formModel->updateFormData('yourtable___parking_hidden', '0', true);
}
else {
  $formModel->updateFormData('yourtable___parking_hidden', '1', true);
}

Then use the hidden yesno as the element you filter on.

-- hugh
 
Hmm.

The only way round that I could think of would be to use another, hidden, element. Maybe a yesno element. And have a simple PHP form submission plugin script which sets it according to the main parking radio ... so something like this, running 'onBeforeProcess', front and back end, edit and new ...

Code:
// change 'yourtable___parking' to the full element name of your main radio
$parking = $formModel->getElementData('yourtable___parking', true);
$parking = is_array($parking) : $parking[0] : $parking;

// replace '0' with whatever the radio option value for "No Parking" is
if ($parking === '0') {
   $formModel->updateFormData('yourtable___parking_hidden', '0', true);
}
else {
  $formModel->updateFormData('yourtable___parking_hidden', '1', true);
}

Then use the hidden yesno as the element you filter on.

-- hugh

Ok.. Just to be sure.

  1. Create a YesNo element, set it to hidden and then set it as the filter.

  2. Go to the form and Create a PHP plugin
    1. Set the Process script to "Start of form submission (onBeforeProcess).

    2. Add the php code based on your example to the PHP code area or in a php file stored in the php/scripts folder.
My questions:
  1. How do I make the YesNo element hidden?

  2. I have more elements to do besides the parking one, can I use the same PHP plugin script instance for all of them or do I need to do one for each?

  3. The parking element doesn't same the store the data as integers, but rather the same data as the labels. Considering this, will the same code you wrote still work? If so, how do I go about assigning the checkbox?

  4. Would it be easier to use filter/query URL appendages and then just add them to the List template? This is what I was thinking of doing, just didn't know yet if the clear the filter link would work or not. If not, I was just going to use a link back to the beach directory URL. I'm not using ajax so it will reload anyways. having issues with ajax for some reason even after changing the template to Protostar). You think this would be an easier way to do it?
 
Last edited:
Yesno can't be hidden (without tricks).
But you can use a simple field element and set it to No/Yes
$formModel->updateFormData('yourtable___parking_hidden', 'No', true);
In element's "List view/Filters" use Dropdown.

You can set multiple of such elements in one php form plugin.

If you want to have a menu item showing only entries with parking you can use your list (without these new elements) and add a prefilter in the menu's "Fabrik options" settings.
 
Ah, yeah, I'd forgotten yesno had no hide option.

But yeah, a simple field will do. I was just thinking a yesno so it could be displayed easily with the tick/cross in list view.

-- hugh
 
Yesno can't be hidden (without tricks).
But you can use a simple field element and set it to No/Yes
$formModel->updateFormData('yourtable___parking_hidden', 'No', true);
In element's "List view/Filters" use Dropdown.

You can set multiple of such elements in one php form plugin.

If you want to have a menu item showing only entries with parking you can use your list (without these new elements) and add a prefilter in the menu's "Fabrik options" settings.

I got it to hide using JavaScript.

Code:
on load : When this element "filter_parking" is shown, hide element "buwb_beaches.filter_parking"

It worked fine.

Also. Thanks for the code example. It does seem simpler. I didn't get to try Hugh's last night, but will try both. Depending on the element I'm using ti for, one may work better then the other based on complexity.
 
I don't recommend "only replace modified files", as ftp clients only use 'last modified date' to figure that out, and there can be all kinds of problems with doing it that way, whereby modified files don't actually get uploaded. I know it's a pain, but I strongly recommend always uploading all files. It takes a while, but makes sure you don't wind up with lurking nastiness, where a change in one file relies on a change in another file, and the "another file" didn't get uploaded.

And doing "only modified files" by hand, based on which files are changed in a commit, is also dangerous, as a change in one commit may implicitly rely on a change made in an earlier commit that you don't have.

-- hugh
 
I don't recommend "only replace modified files", as ftp clients only use 'last modified date' to figure that out, and there can be all kinds of problems with doing it that way, whereby modified files don't actually get uploaded. I know it's a pain, but I strongly recommend always uploading all files. It takes a while, but makes sure you don't wind up with lurking nastiness, where a change in one file relies on a change in another file, and the "another file" didn't get uploaded.

And doing "only modified files" by hand, based on which files are changed in a commit, is also dangerous, as a change in one commit may implicitly rely on a change made in an earlier commit that you don't have.

-- hugh

Agreed. This is why I use template overrides. This way only the modified files I have to worry about updating and not have to worry about which files were modified. Also, all my templates are custom (with different folder names). Of course, I still have the custom template also in the respective Fabrik view folders. Somehow, just creating the custom folder/files in the template/html/com_fabrik/tempalte_name doesn't show up in Fabrik, otherwise. Not a big deal though. While it's not necessary, I still do keep them synced.
 
Also, all my templates are custom (with different folder names). Of course, I still have the custom template also in the respective Fabrik view folders. Somehow, just creating the custom folder/files in the template/html/com_fabrik/tempalte_name doesn't show up in Fabrik, otherwise.

Nope, they won't show up if they only exist in the template overrides location. That's because the stuff in the overrides folder(s) are .... well, overrides. They override something from its original location. If there's nothing matching the override in the original location, the override is superfluous ... there's nothing for it to override. In our template selection menus, we only show what's in the view/tmpl folder. Then when we render that, we look to see if there's an override for it.

When using custom templates, there's no real advantage to using overrides. Overrides are only really useful for overriding Fabrik's built in templates and layouts, so you can change the default behavior, without overwriting any core code (which would then be overwritten by Fabrik the next time you updated). Your own custom templates are your own code, so it's unlikely you'd need to override your own code. So really, you only need the view/tmpl copy, no need to override.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top