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

[3.9] Making the alias menu item multilingual aware (for core menu module only) #22579

Merged
merged 4 commits into from
Oct 24, 2018

Conversation

infograf768
Copy link
Member

@infograf768 infograf768 commented Oct 11, 2018

Pull Request for Issue #22515
Thanks @csthomas for the code to not use the db query

Summary of Changes

Adding $lang parameter to the target menu item when site is multilingual

Testing Instructions

Create a multilingual site. 2 languages are enough.
Use multiple menu items in both languages
Among them create an Alias menu item to a menu item tagged to the other language.
Click on the Alias menu item in frontend.

Before patch

The menu item may display but with the wrong language interface

After patch

Issue solved. One is redirected to the menu item in the other language.

Warning

This will NOT work when not using the core menu module.
It does not break 3rd party menu solutions but they will lack this improvement.

@B3nito
@HLeithner
@csthomas

// Use language code if not set to ALL
if ($language && $language !== '*')
{
$item->flink = $item->flink . '&lang=' . $language;
Copy link
Contributor

Choose a reason for hiding this comment

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

$newItem sometimes may not exists (NULL).

.= would be better

Copy link
Member Author

Choose a reason for hiding this comment

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

I don’t get it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Change to $item->flink .= '&lang=' . $language;

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

If $newItem will be NULL, then you get PHP Warning. It may be when the target item has been deleted, but the alias still exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add if ($newItem != null)

Copy link
Contributor

Choose a reason for hiding this comment

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

Or better if ($newItem != null && $newItem->language && $newItem->language !== '*')

Copy link
Member Author

Choose a reason for hiding this comment

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

I like that one.

Copy link
Contributor

Choose a reason for hiding this comment

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

or if (!empty($newItem->language) && $newItem->language !== '*')

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I will leave it now as it is. ;)

@csthomas
Copy link
Contributor

I have tested this item ✅ successfully on 8704980


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

1 similar comment
@Quy
Copy link
Contributor

Quy commented Oct 11, 2018

I have tested this item ✅ successfully on 8704980


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

@Quy
Copy link
Contributor

Quy commented Oct 11, 2018

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Oct 11, 2018
@mbabker mbabker added this to the Joomla 3.9.0 milestone Oct 24, 2018
@mbabker mbabker merged commit f7bcbf0 into joomla:staging Oct 24, 2018
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 24, 2018
@olejenya
Copy link

olejenya commented Nov 9, 2018

What does happen? http://prntscr.com/lg8r9y

@infograf768 infograf768 deleted the aliasmenumultilingual branch November 9, 2018 12:00
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