New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display category title as page heading and page title when no menu item for com_content category #19195
Conversation
Although this can be useful, it looks like it does not really solve #19192 |
@Bakual |
@infograf768 The page title is set again in parent class, see https://github.com/joomla/joomla-cms/blob/staging/libraries/src/MVC/View/CategoryView.php#L271 So if you want to set title, instead of calling $this->document->setTitle($title); You need to call $this->params->set('page_title', $title); However, I think the logic is more complicated than that. If the active menu item is linked to current category, then page title setting from menu item should be used instead of hard code to category title (just comment base on quick look at the code, so I might be wrong) |
tks, will look later on. |
specific menu item
@joomdonation |
@infograf768 |
@segundochinguel |
I have tested this item ✅ successfully on 2c1afba This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19195. |
1 similar comment
I have tested this item ✅ successfully on 2c1afba This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19195. |
RTC |
if ($this->category->title && strpos($menu->link, 'view=categories&id=')) | ||
{ | ||
$this->params->def('page_heading', $this->category->title); | ||
$title = $title ?: $this->category->title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this code, $title is null, so I I think this line should be changed to $title = $this->category->title;
{ | ||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title)); | ||
$title = $title ?: $this->params->get('page_title', $menu->title); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with above, this line should be changed to $title = $this->params->get('page_title', $menu->title);
If it is possible, I think the code should be changed to: if ($menu
&& $menu->component == 'com_content'
&& isset($menu->query['view'], $menu->query['id'])
&& $menu->query['view'] == 'category'
&& $menu->query['id'] == $this->category->id)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
$title = $this->params->get('page_title', $menu->title);
}
else
{
$this->params->def('page_heading', $this->category->title);
$title = $this->category->title;
$this->params->set('page_title', $title);
} Look a bit longer but it clearly show that the if block is for case current menu item is direct link to the current displayed category. |
@joomdonation, I tried this code correctly. Now, I guess this replaces the previously accepted code. |
Modified to use @joomdonation proposal. Indeed looks cleaner. 👍 |
I have tested this item ✅ successfully on e72d97a This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19195. |
Ready to Commit after two successful tests. |
Pull Request for Issue #19192
Summary of Changes
Patch similar to #12167
Limited to com_content
Steps to reproduce the issue
Create a menu item with the title "Categories" that lists all the categories, when accessing the menu, the page title in the browser shows "Categories" and if I click on any category the browser title does not change.
Expected result
When accessing a category of the list, the title of the category should be displayed in the browser.
Actual result
When accessing a category of the list it continues to show the menu title instead of the title of the category that has been selected .
After patch
The category title will display
Example:
Documentation Changes Required