See articles based on menuitem settings in both category views
See no articles in category with no tags as tag filter remembers flter state form previously visited category with tag filter set in menuitem options
Any Joomla! 3.8
Solution:
/components/com_content/models/articles.php
Original:
line 509: $tagId = $this->getState('filter.tag');
Correct:
line 509: $tagId = JFactory::getApplication()->input->get('filter_tag', 0, 'uint');
Priority | Critical | ⇒ | Medium |
Status | New | ⇒ | Discussion |
I can confirm.
Same exact problem after updating from 3.7.5 to 3.8.0.
This should be fixed ASAP as it renders category blog with tag filtering useless.
The fix is not valid as it means this value cannot be passed through the model state but only through the request data (so it breaks other programmatic uses of the model, i.e. in modules). By default, this particular state value is set from the request data in the same way for this model, so that alone is not the problem.
Category views use the category model on the frontend, and the category model uses the articles model to load data. The category model uses a manner to populate this state value that also uses the active user session. So the fix that is needed is to expand the state keys in a way that allows for multiple active contexts. And this isn't a problem isolated to this particular view or configuration.
I have not tested, line 117 in populateState
, replace:
$value = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', 0, 'int');
by
$value = $app->input->getInt('filter_tag', 0);
No. Again, that removes being able to programmatically set the user state outside the model and forces the value to only be readable from the request. Additionally, some state values are stored to the session so that when you navigate away from a filtered view you return with the same set of filters active.
Again, the problem is not the fact that the state is in use. The problem is in the fact there is not enough uniqueness between state keys for the behavior to work consistently.
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication('site');
$pk = $app->input->getInt('id');
$this->setState('category.id', $pk);
//$value = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', 0, 'int');
$value = $app->input->getInt('filter_tag', 0);
$this->setState('filter.tag', $value);
IMO for programmatically set we use ignore_request
that do not call populateState
in category model
I'm not aware of any fix. I was simply confirming that the problem exists.
Right, for programatic configuration you would pass that flag. But for the default behavior when state is autopopulated, you are breaking more than you are fixing IMO by removing the ability to read and persist the value with the session, and again to fix that requires that the key that is used be more unique than what is basically right now com_content.category.filter.tag
. We have the PK a few lines above that, it is not hard to change the key to basically be com_content.category.filter.$pk.tag
so that the persisted filter states do not apply to everything using the model but only to that specific category ID. If you look later in the function, we are already doing this type of filtering with the menu item ID.
OK, you solution is better. It looks like a search form that should remember the last searched fields per category.
I can also confirm this problem occurs in version 3.8.1.
@qoolman21 @Hurmeli @danielmreck You can test patch at #18248
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-10-05 17:01:59 |
Closed_By | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/18138
Can't confirm.
Setting both Menus as stated above.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18138.