Question -- Frontend Filtering #36

Closed
opened 2017-01-25 08:47:21 +00:00 by mwweb · 1 comment
mwweb commented 2017-01-25 08:47:21 +00:00 (Migrated from github.com)

I have one of my frontend views that I am working on right now. It is the more complex out of all my views, as it will have dropdown filters on the site view. For example, there will be a dropdown for category, that will pre-populate with the categories available for the component which the items on the view can be filtered by, or city which will populate the values in the dropdown with values from the cities table, and if selected would filter by the city selected.

I have all the code that I need to get this working "hard-coded" into the model, which works beautifully, and now I'm working on actually getting the code into the dynamic get. Joining DB tables was fairly simple, and that is compiling with no problems.

Where I'm having struggles right now, and hopefully you have some suggestions, is adding more conditions to protected function getListQuery(). Some samples of the code that I need to get in the getListQuery (there are actually a lot more than this, but this is a sample):

            $categoryDd = $this->input->get('categoryDd');
            if($categoryDd != NULL || $categoryDd != ''){
	$query->where('a.catid = '.$categoryDd);
            }
            $cityDd = $this->input->get('cityDd');
            if($cityDd != NULL || $cityDd != ''){
	$query->where('a.cityid = '.$cityDd);
            }

I've tried putting testing putting $categoryDd = $this->input->get('categoryDd'); in the filter, and the where, but upon compile nothing is showing up in the model.

Any thoughts on this?

I have one of my frontend views that I am working on right now. It is the more complex out of all my views, as it will have dropdown filters on the site view. For example, there will be a dropdown for category, that will pre-populate with the categories available for the component which the items on the view can be filtered by, or city which will populate the values in the dropdown with values from the cities table, and if selected would filter by the city selected. I have all the code that I need to get this working "hard-coded" into the model, which works beautifully, and now I'm working on actually getting the code into the dynamic get. Joining DB tables was fairly simple, and that is compiling with no problems. Where I'm having struggles right now, and hopefully you have some suggestions, is adding more conditions to protected function getListQuery(). Some samples of the code that I need to get in the getListQuery (there are actually a lot more than this, but this is a sample): $categoryDd = $this->input->get('categoryDd'); if($categoryDd != NULL || $categoryDd != ''){ $query->where('a.catid = '.$categoryDd); } $cityDd = $this->input->get('cityDd'); if($cityDd != NULL || $cityDd != ''){ $query->where('a.cityid = '.$cityDd); } I've tried putting testing putting $categoryDd = $this->input->get('categoryDd'); in the filter, and the where, but upon compile nothing is showing up in the model. Any thoughts on this?

Please review the tutorials on dynamic get

IF this is a getListQuery then you can add that script right in the DynamicGet->CustomScript->getListQuery - JModelList I have done it many time and it works great.

But if it is a single item, you will need to do two things with each, add the $var = $this->input->get('xxx') in above the query in before getting the Item the in the Where add a.var in Table Key and $var Value Key

Always type cast an int $query->where('a.catid = '. (int) $categoryDd);

Please review the tutorials on [dynamic get](https://youtu.be/OPuCoxPW35s) IF this is a getListQuery then you can add that script right in the **DynamicGet->CustomScript->getListQuery - JModelList** I have done it many time and it works great. But if it is a single item, you will need to do two things with each, add the `$var = $this->input->get('xxx')` in above the query in _before getting the Item_ the in the **Where** add `a.var` in _Table Key_ and `$var` _Value Key_ Always type cast an int `$query->where('a.catid = '. (int) $categoryDd);`
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#36
No description provided.