1

I have a site which displays a directory of registered users on the frontend. I've allowed users to select topics of interests when they're registering. In the directory they then can search by names or these topics. When the page first loads, the first 6 directory members are displayed. After that, when the users scrolls down I have javascript set up which makes an Ajax call to retrieve more members if needed. It was all working correctly until the latest update to 3.10.4. And I narrowed it down to the Ajax file where it supposed to find if any topics are stored in the state.

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);

In my getListQuery function, when I'm querying for all the items I can then check if the filter.search or 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 filter.search.

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.

2
  • Have you looked at the list of changes between 10.3 and 10.4 to see what has changed that might be causing your issue? Perhaps it is not your code but a change to the core that your code relies on that is broken now or perhaps has tightened the rules that now require you to do something different.
    – Irata
    Feb 1, 2022 at 4:31
  • Yeah, I've looked all over the place and I can't find anything that even gives me a hint. Thanx
    – chavab_1
    Feb 3, 2022 at 20:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.