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

[com_content] Fix layout in category link #20200

Closed
wants to merge 5 commits into from
Closed

[com_content] Fix layout in category link #20200

wants to merge 5 commits into from

Conversation

Septdir
Copy link
Contributor

@Septdir Septdir commented Apr 18, 2018

Pull Request for Issue #20199.

Summary of Changes

Fix bag with ?layout= in com_content category link after #19681

Testing Instructions

If you have this bug, apply the patch

How reproduce bug by @Quy

  • Install the last demo.
  • Under System > Global Configuration > Articles > Integration > URL Routing, select Modern
  • Search Park Blog
  • Hover Park Blog link to see URL:
    http://localhost/joomla387/index.php/using-joomla/extensions/components/content-component/article-category-blog?layout=

Expected result

Link was /category

Actual result

Now link /category?layout= or /category?layout=templatelayout if override com_content category view


if ($layout !== '')
$layout = JFactory::getApplication()->input->get('layout', '', 'string');
if (!empty($layout))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add blank line above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -79,10 +79,8 @@ public static function getCategoryRoute($catid, $language = 0)
$link .= '&lang=' . $language;
}

$jinput = JFactory::getApplication()->input;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO 'cmd' should be better than 'string'

Copy link
Contributor Author

@Septdir Septdir Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if CMD layout was templatelayout and bug still alive if string template:layout this bug was on my site =)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the layout can contain colon, then yes, I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csthomas You were not wrong, just a filter designed for parameters why ignores the colon

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern for CMD is $pattern = '/[^A-Z0-9_\.-]/i';.

There could be a two options: add colon to filter code or replace colon to dot in layout.
The same as work for task=controller.method.

At now you do not have an option, stay with string.

$jinput = JFactory::getApplication()->input;
$layout = $jinput->get('layout');

if ($layout !== '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a cosmetic suggestion. Instead of if (!empty($layout)) would be better to use if ($layout). We do not need to check if $layout is set.

Copy link
Contributor Author

@Septdir Septdir Apr 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I somehow did not even think. Done

@brianteeman
Copy link
Contributor

brianteeman commented Apr 18, 2018 via email

@Septdir
Copy link
Contributor Author

Septdir commented Apr 18, 2018

@brianteeman I, too, failed to reproduce the bug on the newly installed joomla, can only suggest creating an alternative / override layout for the test

But I can provide details of why #19681 caused a bug

In the past, PR layout turned out so

$jinput = JFactory::getApplication()->input;
$layout = $jinput->get('layout');

if ($layout !== '')
{
	$link .= '&layout=' . $layout;
}

What led to the following results

  1. If category view use standard blog layout layout = NULL NULL !== ''
    It was on two of my test sites updated with 3.8.6 to 3.8.7
  2. If category use alternative/override layout layout = templatelayout And for the correct formation of a link layout = template:layout With a colon as a separator
    It was on several client sites. And if they did not notice, then maybe in a week or two, the search results will have duplicate pages. That will negatively seo affect

This code will correctly add layout to the link

$layout = JFactory::getApplication()->input->get('layout', '', 'string');

if ($layout)
{
	$link .= '&layout=' . $layout;
}

In fact in this PR, I just corrected what was added by the filter 'string' and changing the check

@Quy
Copy link
Contributor

Quy commented Apr 18, 2018

  • Install the last demo.
  • Under System > Global Configuration > Articles > Integration > URL Routing, select Modern
  • Search Park Blog
  • Hover Park Blog link to see URL:
    http://localhost/joomla387/index.php/using-joomla/extensions/components/content-component/article-category-blog?layout=

@Quy
Copy link
Contributor

Quy commented Apr 18, 2018

I have tested this item ✅ successfully on f8ad03c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20200.

@Septdir
Copy link
Contributor Author

Septdir commented Apr 18, 2018

@Quy I tried to reproduce this bug with a clean installation of joomla on one of my subdomains, But I could not reproduce the bug.

Thank you.
Added your instruction How reproduce to the description

@ReLater
Copy link
Contributor

ReLater commented Apr 19, 2018

I have tested this item ✅ successfully on f8ad03c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20200.

@Quy
Copy link
Contributor

Quy commented Apr 19, 2018

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20200.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Apr 19, 2018
@Septdir
Copy link
Contributor Author

Septdir commented Apr 22, 2018

Then what. If you display a module with links to com_tags or view article with its layout, then again there will not be a correct link.

@ReLater , @Quy Please test again.

P.S ontinuous-integration/drone/pr — the build failed?

@Septdir
Copy link
Contributor Author

Septdir commented Apr 22, 2018

In fact, I would delete the addition of layout to the link, because personally I think it is not correct #19681 PR.

Because if I choose another for another language I choose another layout. Maybe I need to have another layout.

If there are those who think the same way, Say and I just delete the layout from the formation of the link in this PR

@Septdir
Copy link
Contributor Author

Septdir commented Apr 22, 2018

Create new PR #20211 with full revert #19681
Please test

@Septdir Septdir closed this Apr 22, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Apr 22, 2018
@Septdir Septdir deleted the fix-layout-in-category-link branch April 22, 2018 18:33
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