Skip to content
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

Merged
merged 3 commits into from Jan 15, 2018

Conversation

infograf768
Copy link
Member

@infograf768 infograf768 commented Dec 28, 2017

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:
screen shot 2017-12-28 at 10 06 35

Documentation Changes Required

@infograf768
Copy link
Member Author

Although this can be useful, it looks like it does not really solve #19192

@infograf768
Copy link
Member Author

@Bakual
It looks like we do get the correct $title with the PR (did a var_dump line 219), but that the Head is reloaded and displays the former menu title.

@joomdonation
Copy link
Contributor

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

@infograf768
Copy link
Member Author

tks, will look later on.

@infograf768
Copy link
Member Author

@joomdonation
By checking for view=categories&id= I got sure the category name is only displayed when there is no specific menu item for that category.
Below, Fruit Shop Site, has no menu item.
cat_title

@infograf768 infograf768 changed the title Display category title as page heading when no menu item for com_content category Display category title as page heading and page title when no menu item for com_content category Dec 28, 2017
@segundochinguel
Copy link

@infograf768
I saw the gif and it does exactly what I was looking for. I have not implemented it yet, but I trust that was the solution. I had trying to overwrite view.html.php in category, but without results. You may not close the case until you try it in a few hours.

@infograf768
Copy link
Member Author

@segundochinguel
Please mark the PR as successful on https://issues.joomla.org/tracker/joomla-cms/19195

@segundochinguel
Copy link

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
@Quy
Copy link
Contributor

Quy commented Jan 9, 2018

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.

@Quy
Copy link
Contributor

Quy commented Jan 9, 2018

RTC

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 9, 2018
@infograf768 infograf768 added this to the Joomla 3.8.4 milestone Jan 9, 2018
if ($this->category->title && strpos($menu->link, 'view=categories&id='))
{
$this->params->def('page_heading', $this->category->title);
$title = $title ?: $this->category->title;
Copy link
Contributor

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);
Copy link
Contributor

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

@joomdonation
Copy link
Contributor

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.

@segundochinguel
Copy link

@joomdonation, I tried this code correctly.

Now, I guess this replaces the previously accepted code.

@infograf768
Copy link
Member Author

infograf768 commented Jan 10, 2018

Modified to use @joomdonation proposal. Indeed looks cleaner. 👍
@segundochinguel
@Quy
Please test and mark OK on https://issues.joomla.org/tracker/joomla-cms/19195

@Quy
Copy link
Contributor

Quy commented Jan 10, 2018

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.

@joomla-cms-bot joomla-cms-bot removed this from the Joomla 3.8.4 milestone Jan 14, 2018
@ghost
Copy link

ghost commented Jan 14, 2018

Ready to Commit after two successful tests.

@mbabker mbabker added this to the Joomla 3.8.4 milestone Jan 15, 2018
@mbabker mbabker merged commit a905334 into joomla:staging Jan 15, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 15, 2018
@infograf768 infograf768 deleted the cat_title_content branch January 16, 2018 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants