For the filtering, I added a simple search text field. Then I created a checkboxes list to select the topics to filter by. The items in the checkboxes are being feed from a little database that has all the available topics. In the model's populate state function I included the code to save the state for the
filter.search input field. I just copied it from another component. But for the topics, since it's not really a filter, I added this code to save the state:
$postData = Factory::getApplication()->input->post; $data = $postData->get('jform', , 'array'); $topics = $data['topicsinterest'] ?? ; $this->setState('filter.topics', $topics);
getListQuery function, when I'm querying for all the items I can then check if the
filter.topics are set and then adjust the query accordingly. On initial page load, everything works fine when trying to filter members. When the user tries to scroll to view more members, the Ajax call is sent and this is where the problem lies. It works fine only if I'm using
This is the code that I'm using in my Ajax file:
JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_memberdirectory/models', 'MemberdirectoryModelMembers'); $model = JModelLegacy::getInstance('members', 'MemberdirectoryModel'); $search = $model->getState('filter.search'); $topics = $model->getState('filter.topics');
$search gets me the state data if it's there, but
$topics always returns an empty array. It used to work just fine before the latest update.
I think it has to do with how I'm saving the state since it's different from the default filters. But I don't understand why if the state is being saved, why can't I retrieve it from any other file.
Any help would be appreciated.