User tests: Successful: Unsuccessful:
Pull Request resolves #19453.
Modified the PageNavigation plugin to respect the Include Subcategories: All setting when generating article-to-article navigation (Next/Previous).
Previously, navigation only cycled through articles in the current category. Now, when a Category Blog menu item has Include Subcategories: All enabled, navigation includes articles from all subcategories as well.
File changed: plugins/content/pagenavigation/src/Extension/PageNavigation.php
Create category structure:
Create articles:
Create Category Blog menu item:
Include Subcategories: AllNavigation: ShowTest navigation:
Navigation only cycles through articles in the current category:
Navigation cycles through all articles in the parent category AND all its subcategories:
Please select:
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End Plugins |
| Labels |
Added:
PR-5.4-dev
|
||
@CSGoat0 In my installation there is a category called Modules ( 2 articles ) which has multiple subcategories one of which is Content Modules ( 12 articles ) and i can only navigate 14 articles using the next button [ The articles from the other subcategories are excluded ]
Another problem is that when i click next and i go from an article that belongs to Modules to an article that belongs to Content Modules i should see a prev button that takes me back to the article that belongs to Modules, but there is no prev button ( ie I can only cycle articles from Content Modules using the next and prev buttons)
perhaps it has to do something with the fact that all the articles mentioned above ( that belong to content modules category ) are menu items elsewhere themselves so the URL is resolving to reflect that.
Hello @hiteshm0 , I have did those steps:
If you think I missed something, please tell me what I should do.
If that works for me as you expect but not for you, then I suggest to:
@CSGoat0
assign one of the child category articles as a single article menu item in a different menu.
Now try to access it from the parent category blog ( for which navigation is set to show ) you still can't see the prev and next buttons because you are using the current menu items URL ( $active = $menu->getActive();) which might have shifted contexts ( ie the context of the parent category blog might be lost ).
There is also a bigger problem that will be more difficult to solve.
If the single article menu item mentioned above has its options -> navigations explicitly set to hide instead of global then once you click next and get to that article you will lose both the prev and next button ( and the articles that were supposed to appear after it will not be accessible by navigating using those buttons )
@CSGoat0 assign one of the child category articles as a single article menu item in a different menu.
Now try to access it from the parent category blog ( for which navigation is set to show ) you still can't see the prev and next buttons because you are using the current menu items URL (
$active = $menu->getActive();) which might have shifted contexts ( ie the context of the parent category blog might be lost ).There is also a bigger problem that will be more difficult to solve. If the single article menu item mentioned above has its options -> navigations explicitly set to hide instead of global then once you click next and get to that article you will lose both the prev and next button ( and the articles that were supposed to appear after it will not be accessible by navigating using those buttons )
@hiteshm0
Thank you for the detailed testing and for identifying this edge case.
You're correct that when an article has its own single article menu item, the navigation context can be lost because $active changes. Solving this would require storing navigation state (e.g., in the session), which would introduce other issues like stucking on the same category blog and unable to view anything else due to the stored value.
Also, the URL solution is because the catid of the category blog menu unfortunately doesn't bind to the absolute parent category id (rather, just a random one). so, it will never work even in the base context.
Given those trade-offs, my fix addresses the primary use case: navigation within a Category Blog context when Include Subcategories: All is enabled. I believe this is an improvement over the current behavior.
I am open to discuss another solution if you have one in mind.
Thanks again for your thorough review!
@CSGoat0
On a live site, most articles will be menu items one way or the other. This consistently works only when the articles are in the backend but not on the site in any way except for being part of the category blog.
And, you might get locked away from the parent category having access only to the articles from a child category through navigation. Which is just another bug.
We should wait for the opinion of someone more experienced
@CSGoat0 On a live site, most articles will be menu items one way or the other. This consistently works only when the articles are in the backend but not on the site in any way except for being part of the category blog. And, you might get locked away from the parent category having access only to the articles from a child category through navigation. Which is just another bug.
We should wait for the opinion of someone more experienced
@hiteshm0
This is a limitation of how Joomla determines the active menu item.
The old implementation never allowed parent↔child navigation at all. This PR enables it for the majority of cases where articles don't have their own menu items.
I agree this edge case exists, but fixing it would require a more fundamental change to how Joomla tracks navigation context across menu items — which is outside the scope of this PR. I just enhanced the db Query.
And yes, you are right. Either case, an experienced maintainer should decide.
@CSGoat0
In my installation there is a category called Modules ( 2 articles ) which has multiple subcategories one of which is
Content Modules ( 12 articles ) and i can only navigate 14 articles using the next button [ The articles from the other subcategories are excluded ]
Another problem is that when i click next and i go from an article that belongs to Modules to an article that belongs to Content Modules i should see a prev button that takes me back to the article that belongs to Modules, but there is no prev button ( ie I can only cycle articles from Content Modules using the next and prev buttons)
perhaps it has to do something with the fact that all the articles mentioned above ( that belong to content modules category ) are menu items elsewhere themselves so the URL is resolving to reflect that.