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

Duplicated title (item type) in Menus: Items (Administration) #12682

Closed
PhocaCz opened this issue Nov 1, 2016 · 9 comments
Closed

Duplicated title (item type) in Menus: Items (Administration) #12682

PhocaCz opened this issue Nov 1, 2016 · 9 comments

Comments

@PhocaCz
Copy link
Contributor

PhocaCz commented Nov 1, 2016

Steps to reproduce the issue

Joomla! 3.6.4 - Create a menu link to some extension, in my case e.g. Phoca Download. When menu item is created, then the item type is duplicated, see image:

Duplicated Items

Expected result

The item type is not duplicated - as it worked in past since Joomla! 2.5 (1.7)

Actual result

The item type is duplicated

System information (as much as possible)

Joomla! 3.6.4, PHP5, PHP7, MySQL

Additional comments

The item type is managed here:
administrator\components\com_menus\views\items\view.html.php

$viewTitle = trim((string) $view[0]['title']);
// Check if the key is valid. Needed due to B/C so we don't show untranslated keys. This check should be removed with Joomla 4.
if ($lang->hasKey($viewTitle))
{
	$titleParts[] = JText::_($viewTitle);
}

In case, there is set some string which is not translatable (no translation found), then menu item type is not duplicated, see example: com_content Article, see:

components\com_content\views\article\metadata.xml

<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<view
		title="Article">
		<message><![CDATA[TYPEARTICLAYDESC]]></message>
	</view>
</metadata>

In case the "title" attribute includes string which can be found in translation, then the item type will be duplicated.

The question is, is this a bug? Or is this some change?

In past, the translated string was not duplicated, so this XML:

<?xml version="1.0" encoding="utf-8"?>
<metadata>
	<view title="COM_PHOCADOWNLOAD_CATEGORY_GROUP">
		<message><![CDATA[COM_PHOCADOWNLOAD_CATEGORY_GROUP_DESC]]></message>
	</view>
</metadata>

which includes string found in translation was not duplicated.

The XML with translatable strings works since version 2.5 (1.7)

@brianteeman
Copy link
Contributor

I have just tested this and can confirm the issue with phoca downloads and phoca gallery but I cannot confirm it with other extensions I tested with which were acymailing and jevents


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

@Bakual
Copy link
Contributor

Bakual commented Nov 2, 2016

In the past, the view title (translated or not) wasn't used anywhere at all. However it was a required field. Which was obviously stupid.
With #7654 we changed that so the view title is shown if it is translated, assuming the extension developer wanted it to be shown.
In your case, you can either remove it completely from the view metadata.xml, but that would create issues before Joomla 3.5.0, or you just change the title to some untranslated string, or you change the translation to something useful so "Component > View > Layout" makes sense.

@brianteeman
Copy link
Contributor

So is this is a bug in core that needs fixing or just something for @PhocaCz to fix in their own extension?


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

@Bakual
Copy link
Contributor

Bakual commented Nov 2, 2016

It's an expected side effect of the referenced PR. It's the same what happend in core with the wrapper ("Wrapper » Wrapper » Iframe Wrapper"). The wrapper thing was fixed with #8108

@brianteeman
Copy link
Contributor

brianteeman commented Nov 2, 2016 via email

@Bakual
Copy link
Contributor

Bakual commented Nov 2, 2016

I wanted to hear the opinion of @PhocaCz first. From my point of view it can be closed. But the referenced PRs were both mine, so I'm a bit biased here 😄

@PhocaCz
Copy link
Contributor Author

PhocaCz commented Nov 2, 2016

Hi, first of all, it is not about Phoca extensions, you can see on the screenshot, that e.g. JComments behaves the same. I would say it is about extensions they just follow the rules.

In your case, you can either remove it completely from the view metadata.xml, but that would create issues before Joomla 3.5.0, or you just change the title to some untranslated string, or you change the translation.

Yes, this is the problem, this will behave differently in different Joomla! 3.x versions. Just imagine, I have made over 100 views in different extensions. There was some rule in Joomla! and now it was changed easily with ignoring extensions developers who do their job properly (follow the rules which was set). So the feature has worked for some years properly and now with inconsiderate change you just say: "Yes, ok, you have followed the rules but we changed them, just do a small change". But it is not about small change. I lose so much time which I can use for developing new extensions. It is not only this change. In history there were so many similar changes, the bad is, you never know if such change will be not reversed back. Like happened more times. Nonsense change - I, as developer who wants to do all the features properly - I changed it to new rules- then in some of next version, the old feature was set back. I really don't understand :-(

just change the title to some untranslated string

This is something which I cannot do, this is against all the rules, against all the principles. The code must be so bad written, if the feature is based on translation (if found, do something, if not, do something else). :-(

The problem is, I am trying always to meet the rules in Joomla!. The rule was to translate all the strings properly. Of course if somebody does not follow the rules, its extensions do not have any problems with such kind of changes. But, purposely do a mistakes (change string to some which will be not found in translation: FROM: COM_EXTENSION_WELCOME to COM_EXTENSION_WALCOME or Welcome), this is really something I really don't know :-(

When Joomla! 1.6 was released, the advice, recommendation and wish from Joomla! core team was to translate all the strings. Now, it is: do not translate everything?

@Bakual
Copy link
Contributor

Bakual commented Nov 2, 2016

I would say it is about extensions they just follow the rules.

In core, the view title wasn't translated except in the wrapper. So if you had the view title translated, you technically didn't follow core (but maybe the "rules").

So the feature has worked for some years properly

I'm not sure if you were aware, but the view title was broken at least since Joomla 3.0, and I think it was even broken back since J1.6. The view title never was used anywhere and thus any translation made was a complete waste of time. At the same time the view title was a required element in the metadata.xml, which by itself was required as well.
My PR allowed to
a) have the view title appear. To avoid popping up untranslated strings I added that check (which should be removed with 4.0)
b) make the metadata.xml optional as the only reason we have it so far was to specify the unused title. Pretty pointless, right?

I was fully aware and pointed it out in the PR that when an extension developer translated the view title, it will show up in the menu manager. As it is only a visual thing, I thought that should be acceptable. On the other side extension developer are now more flexible in how the menu manager shows the menu item type.

The code must be so bad written, if the feature is based on translation (if found, do something, if not, do something else). :-(

Yes, I agree it's sort of a hack. But it's meant as a temporary solution until Joomla 4.0. And the code before was even worse: Requiring something which isn't used anywhere wasn't making any sense while the view title actually would be a useful information to show in some cases.
Easiest thing you could do is a search over all metadata.xml and change the title to <title>this is stupid</title> in every metadata.xml you find. If you ever raise the minimum requirement to 3.5 or higher, you can even delete all view metadata.xml files (if you don't use the params feature in it).

If you see a better approach which allows to show the view title (optionally), then I'm all ears. The current solution may not be perfect, but it is the best I could come up with.

@PhocaCz
Copy link
Contributor Author

PhocaCz commented Nov 2, 2016

Ok, thank your for the answer, so you can just mark it as closed.

Thank you, Jan

@Bakual Bakual closed this as completed Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants