User tests: Successful: Unsuccessful:
Pull Request resolves #48710 .
Fixes #48710
CategoryView::prepareDocument() in libraries/src/MVC/View/CategoryView.php was only reading metadata from the active menu item params ($this->params), completely ignoring $this->category->metadesc and $this->category->metadata.
As a result, for components relying on CategoryView (such as com_contact and com_newsfeeds), setting Robots or Meta Description on a category had zero effect on the frontend category view.
While com_content previously solved this in its own component-specific HtmlView, the shared base class CategoryView was never updated. This fix brings that capability centrally into CategoryView so all extending components benefit without duplicated logic.
metadesc now takes precedence over menu item meta description, falling back to the menu item if empty.$this->category->metadata (e.g. robots, author, rights) and applies it after the menu item check, allowing category-level directives to override menu item defaults.noindex, follow. Save.Use Global.Ctrl + U).
No <meta name="robots"> tag appears in the <head> (or global default is rendered). The category's noindex, follow directive is completely ignored.
<meta name="robots" content="noindex, follow"> is correctly output in the <head>.
None.
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
Hey @Devansh-dvd, just a heads-up: #48728 was opened earlier for the same issue (#48710) and already has a test. Yours fixes it in the shared
CategoryView, which also covers newsfeeds, so maybe the maintainers can pick whichever they prefer. Happy to adjust mine either way!
@Devansh-dvd In addition, please mind that 5.4 has reached end of bugfix support and entered security only support, which lasts one more year. That means PRs for bugfixes should be made for the 6.2-dev branch, not for the 5.4-dev branch.
Finally note that we will not accept PRs where the confirmation of the AI policy has been removed.
| Labels |
Added:
PR-5.4-dev
|
||
| Category | Libraries | ⇒ | Repository Administration com_admin SQL |
This pull request has conflicts, please resolve those before we can evaluate the pull request.
| Title |
|
||||||
| Category | Repository Administration com_admin SQL | ⇒ | Libraries |
hi @richard67
Thank you for clarifying! I have rebased the branch onto 6.2-dev, updated the target branch and title to 6.2, and added the Generative AI policy confirmation checkbox to the PR description.
I have tested this item ✅ successfully on 5bc4417
Verdict: works as intended. One behaviour change in com_content worth stating in the description (below).
6.2-dev + PR (DDEV, PHP 8.3, MariaDB 11.8). One category per component, each with a category menu item. Values set on the category and/or the menu item, then the <head> of the category page read as a guest. Before = same instance with CategoryView.php from 6.2-dev.
| Category / menu item | contact before → after | newsfeeds before → after | content before → after |
|---|---|---|---|
category Robots noindex, follow, menu "Use Global" |
– → noindex, follow |
– → noindex, follow |
noindex, follow (unchanged) |
| category Meta Description | – → category | – → category | category (unchanged) |
| category Author | – → Cat Author |
– → Cat Author |
Cat Author (unchanged) |
category Robots noindex, follow + menu Robots index, nofollow |
menu → category | menu → category | menu → category |
| category + menu Meta Description | menu → category | menu → category | menu → category |
| only menu Robots / Description | menu (unchanged) | menu (unchanged) | menu (unchanged) |
Subcategory reached through the parent's menu item uses its own Robots; without own values it keeps the menu's. The testing instructions done through the category form (Publishing tab) work: <meta name="robots" content="noindex, follow"> and the description are in the head. Existing system tests site/com_content/Category, Categories, site/com_contact/Category, Categories pass, as does the new test from #48728 (applies the robots metadata of the category to the category page). php-cs-fixer and phpstan clean.
HtmlView::display() already applied the category values, but then parent::display() → CategoryView::prepareDocument() set the menu Robots/Description again, so the menu item won when both were set. Now the category wins there as well. That matches the article, contact and newsfeed item views (item metadata over menu), but it changes the output of existing sites with both set, so please mention it in the description.components/com_content/src/View/Category/HtmlView.php::display() is now done twice and could be removed.I have tested this item ✅ successfully on 5bc4417
Verdict: works as intended. One behaviour change in com_content worth stating in the description (below).
6.2-dev + PR (DDEV, PHP 8.3, MariaDB 11.8). One category per component, each with a category menu item. Values set on the category and/or the menu item, then the <head> of the category page read as a guest. Before = same instance with CategoryView.php from 6.2-dev.
| Category / menu item | contact before → after | newsfeeds before → after | content before → after |
|---|---|---|---|
category Robots noindex, follow, menu "Use Global" |
– → noindex, follow |
– → noindex, follow |
noindex, follow (unchanged) |
| category Meta Description | – → category | – → category | category (unchanged) |
| category Author | – → Cat Author |
– → Cat Author |
Cat Author (unchanged) |
category Robots noindex, follow + menu Robots index, nofollow |
menu → category | menu → category | menu → category |
| category + menu Meta Description | menu → category | menu → category | menu → category |
| only menu Robots / Description | menu (unchanged) | menu (unchanged) | menu (unchanged) |
Subcategory reached through the parent's menu item uses its own Robots; without own values it keeps the menu's. The testing instructions done through the category form (Publishing tab) work: <meta name="robots" content="noindex, follow"> and the description are in the head. Existing system tests site/com_content/Category, Categories, site/com_contact/Category, Categories pass, as does the new test from #48728 (applies the robots metadata of the category to the category page). php-cs-fixer and phpstan clean.
HtmlView::display() already applied the category values, but then parent::display() → CategoryView::prepareDocument() set the menu Robots/Description again, so the menu item won when both were set. Now the category wins there as well. That matches the article, contact and newsfeed item views (item metadata over menu), but it changes the output of existing sites with both set, so please mention it in the description.components/com_content/src/View/Category/HtmlView.php::display() is now done twice and could be removed.I have tested this item ✅ successfully on 5bc4417
I have tested this item ✅ successfully on 5bc4417
| Status | Pending | ⇒ | Ready to Commit |
| Build | 5.4-dev | ⇒ | 6.2-dev |
RTC
RTC
| Easy | No | ⇒ | Yes |
RTC
RTC
| Labels |
Added:
RTC
PR-6.2-dev
Removed: PR-5.4-dev |
||
Hey @Devansh-dvd, just a heads-up: #48728 was opened earlier for the same issue (#48710) and already has a test. Yours fixes it in the shared
CategoryView, which also covers newsfeeds, so maybe the maintainers can pick whichever they prefer. Happy to adjust mine either way!