-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[4.0] Multilingual : Correcting info-block category and parent category urls #21916
Changes from 1 commit
299689a
e50668a
c1d382f
c21eb52
2141933
70f455e
f3dc6e9
e06a014
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,13 +115,16 @@ public function display($tpl = null) | |
|
||
foreach ($items as $item) | ||
{ | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->catlanguage = $item->category_language; | ||
$item->parentlanguage = $item->parent_language; | ||
|
||
// No link for ROOT category | ||
if ($item->parent_alias === 'root') | ||
{ | ||
$item->parent_slug = null; | ||
$item->parent_slug = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you revert this change here? Don't want to have unnecessary changes... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
} | ||
|
||
$item->event = new \stdClass; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,9 +107,11 @@ public function display($tpl = null) | |
$item->tagLayout = new FileLayout('joomla.content.tags'); | ||
|
||
// Add router helpers. | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->catlanguage = $item->category_language; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->parentlanguage = $item->parent_language; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, don't duplicate the attributes and we don't need the slugs. |
||
|
||
// No link for ROOT category | ||
if ($item->parent_alias === 'root') | ||
|
@@ -302,7 +304,7 @@ protected function _prepareDocument() | |
|
||
while ($category && ($menu->query['option'] !== 'com_content' || $menu->query['view'] === 'article' || $id != $category->id) && $category->id > 1) | ||
{ | ||
$path[] = array('title' => $category->title, 'link' => \ContentHelperRoute::getCategoryRoute($category->id)); | ||
$path[] = array('title' => $category->title, 'link' => \ContentHelperRoute::getCategoryRoute($category->id, $category->language)); | ||
$category = $category->getParent(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,17 +93,18 @@ public function display($tpl = null) | |
// Compute the article slugs and prepare introtext (runs content plugins). | ||
foreach ($this->items as $item) | ||
{ | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
|
||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->catlanguage = $item->category_language; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->parentlanguage = $item->parent_language; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, don't duplicate the attributes and we don't need the slug. |
||
|
||
// No link for ROOT category | ||
if ($item->parent_alias === 'root') | ||
{ | ||
$item->parent_slug = null; | ||
} | ||
|
||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->event = new \stdClass; | ||
|
||
// Old plugins: Ensure that text property is available | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,9 +140,11 @@ public function display($tpl = null) | |
// Compute the article slugs and prepare introtext (runs content plugins). | ||
foreach ($items as &$item) | ||
{ | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; | ||
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; | ||
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; | ||
$item->catlanguage = $item->category_language; | ||
$item->parentlanguage = $item->parent_language; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above... |
||
|
||
// No link for ROOT category | ||
if ($item->parent_alias === 'root') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Categories\CategoryNode; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Language\Multilanguage; | ||
|
||
/** | ||
|
@@ -77,17 +78,17 @@ public static function getCategoryRoute($catid, $language = 0) | |
{ | ||
$link = 'index.php?option=com_content&view=category&id=' . $id; | ||
|
||
if ($language && $language !== '*' && Multilanguage::isEnabled()) | ||
if ($language && Multilanguage::isEnabled()) | ||
{ | ||
$link .= '&lang=' . $language; | ||
} | ||
|
||
$jinput = JFactory::getApplication()->input; | ||
$layout = $jinput->get('layout'); | ||
|
||
if ($layout !== '') | ||
{ | ||
$link .= '&layout=' . $layout; | ||
if ($language !== '*') | ||
{ | ||
$link .= '&lang=' . $language; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you undo changes that do not do anything in this file, I mean just delete the part with the layout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do |
||
else | ||
{ | ||
$lang = Factory::getLanguage()->getTag(); | ||
$link .= '&lang=' . $lang; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The $lang changes should not be necessary. It defaults to the current language if no language is given. Did you check if this is necessary? The $layout is indeed wrong here. In any case, you should change the fingerprint of these methods to not have the $language (and also the $catid) be optional anymore. These are always required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Alas it is. Tested that. Specially for the info-block at least. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Any hint how to do that? And would it be B/C ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply remove the optional parameter stuff here. So from
to
This is not B/C, but we are talking about Joomla 4.0 here, where we can break B/C and this is a case where we have to break it, to clear up this longlasting bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please remove the $lang changes. We should never have to add something if the language is *. If this currently is necessary, we have to fix this in another place, but not here. Not only because it is wrong, but also because this method is just an amenity, not a necessity. These methods only concatenate a string, nothing more, they don't look up anything. People can also just hand in their own handcrafted URL into the router, which could not contain the language parameter. So we have to see what the issue is here in the router and fix that and not hand in fake parameters. This code has to go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My problem here is that if I remove it, full tests can't be done on this PR as soon as we have a category set to ALL languages.
I would also do for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a solution for the $lang stuff. Will add later on. |
||
} | ||
} | ||
|
||
|
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.
Why are you adding these attributes again here? We don't need to duplicate these attributes.
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.
We also don't need the slugs for the categories. For the categories we only need the ID.
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.
Looks like they are needed for the info-block JLayout
I was adapting to the info-block layout which uses slugs.