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

Menu items without label are removed from the menu #256

Closed
herrvigg opened this issue Jun 22, 2018 · 19 comments
Closed

Menu items without label are removed from the menu #256

herrvigg opened this issue Jun 22, 2018 · 19 comments
Labels
legacy issue Legacy issue imported from original repo need info The submitter must provide more info

Comments

@herrvigg
Copy link
Collaborator

Issue by cdauth
Friday Sep 11, 2015 at 13:51 GMT
Originally opened as qTranslate-Team/qtranslate-x#256


Menu items with an empty label are removed from the menu. For example, when adding a page that only has an English translation (and thus its Italian title is empty), in the Italian version of the menu this page will be missing. This behaviour is unexpected, as there is a setting “Hide Content which is not available for the selected language”, which is not respected for menus.

The expected behaviour would be that either the “Hide Content” setting is respected for menu items with an empty label, or even better to have a separate global or per-menu setting for this specific issue.

@herrvigg herrvigg added legacy issue Legacy issue imported from original repo need info The submitter must provide more info labels Jun 22, 2018
@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Friday Sep 11, 2015 at 17:41 GMT


Correct, "Hide Content .." is for content of posts and pages only, not menu, not widgets etc. Empty menu labels allow to manipulate menus in a more flexible way. How would you show menu item with empty label anyway? What is it exactly you are trying to achieve?

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Friday Sep 11, 2015 at 18:12 GMT


I would display it in the same way that any other content is displayed, if there is no translation, fall back to the default language.

I have a website where a few pages are translated into a lot of languages, and a lot of pages are only in English. What I'm trying to achieve is that all menu items appear in all languages, even if the page is not translated into that language. With the way that qtranslate-x currently works, I would have to copy the English page title / menu item label into every language where a translation doesn't exist.

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Friday Sep 11, 2015 at 19:36 GMT


I would display it in the same way that any other content is displayed, if there is no translation, fall back to the default language.

Menu items do not change dynamically, like content does, that is why it is assumed that an administrator tunes all menu items as needed, and no trick is necessary to show empty items in English, since the administrator can always fill it in appropriately. I believe it is good enough design and no changes are needed.

I would have to copy the English page title / menu item label into every language where a translation doesn't exist.

I do not really understand why it is so. What is wrong with empty title on a page? The content in English is still shown, is not it?

Maybe a list of steps to reproduce the problem under a simple standard theme with the minimum of active plugins can help to understand what you mean?

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Sunday Sep 13, 2015 at 10:06 GMT


I tried to reproduce the problem with these steps:

  1. Create a page that has content and title only in the default language
  2. Add this page to the menu without typing in any labels
  3. Open Wordpress in a language that is not the default language and see if the menu item is there

When I just tested it, it actually worked and the menu item was there with the title in the default language. But when I add any existing pages (that also have only a title and content in the default language) to the menu, they are not displayed in the menu. I need to investigate more to find out how this happens.

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Sunday Sep 13, 2015 at 15:18 GMT


In this case you would need to fill menu labels manually. Page can be translated later, but menu is supposed to be always translated and fully ready. You may still put English there temporarily.

String like "(English) Text" would look awkward in menu anyway. In many cases, one wish menu item to have a little bit different text, than the page title. WP puts there page title by default, just to have something in menu, assuming that admin will change it. That it the currently designed approach, which seems to work for the majority of the cases.

I would not mind to change the design, like if menu item is the default, meaning not altered by the admin and gets from the page title, then apply your rule. And I am sure there will be someone who would still want it back to how it is now, so it needs to be on an option. Due to a low demand on this feature it would get a low priority for us, but you are more than welcome to figure out the code for this and to submit a pull request. Please, make sure that the current functionality stays intact by default in order not to break anyone's site.

I will close the issue for now, we can still write into closed issue or can reopen it when needed. If you submit a pull request, refer to this issue.

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Wednesday Sep 16, 2015 at 11:13 GMT


In my case, most of the pages only exist in English, so it would be a ridiculous amount of work to set the label of hundreds of pages in all the languages.

About the "(English) Text" I agree, that’s why I disabled the option to add that prefix.

About backwards compatibility, we were using qtranslate and then mqtranslate before, and both were not removing the untranslated items from the menu. So I think the current behaviour also breaks a lot of sites when they migrate to qtranslate-x.

I will create a pull request that adds an option as soon as I find time.

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Wednesday Sep 16, 2015 at 16:47 GMT


of hundreds of pages

Do you have hundreds of menu entries? Normally menu is less than 40-50 items and it does not change every day, almost never actually, is not it your case? I am sorry I am still trying to understand why this is a problem for you. I would think that, right the opposite, people would like to have all menu is properly done and nicely translated, while pages themselves can change and can be translated later.
Do you dynamically change menu to be pointed to different pages like every day?

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Friday Nov 27, 2015 at 02:29 GMT


My use case is a page for a volunteer-based project. The page is edited by a lot of different people who don't communicate with each other a lot, many people are only temporarily involved in the project and will only edit a few things on the website. The site has about 75 pages and currently 11 languages set up. In most of those languages, a translation for the front page and maybe one or two other pages have been contributed by volunteers, the rest is only available in English. It makes a lot of sense to have these translations, as people who don't speak English will get a general overview about the project on the front page, but it also makes sense to show all pages that have not been translated, so that at least those who do speak English will see that there is more information available.

The problem is that content is often created by people whose only involvement in the website is to create one page or add one language to provide the translation for one page, and those people will neither know nor guess that when they create a menu entry, they will have to copy the page title to all the other languages (or in case they set up a new language, to copy the page titles of all 75 pages in the menu to the new language).

(The other thing is that the menu recently got lost because of the max_input_vars issue, and now I would have to paste about 75*10 page titles to make the menu complete in all languages).

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Friday Nov 27, 2015 at 02:32 GMT


(Note to self and in case someone else has the same issue: The workaround is to edit qtranxf_wp_get_nav_menu_items() in qtranslate_frontend.php and set the last parameter to false in all occurrences of qtranxf_use_language($language, <…>, false, true).)

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Friday Nov 27, 2015 at 18:21 GMT


I am sorry about lose of menu. I thought that when max_input_vars error appears it does not remove old items, it just does not let you insert new ones. This is the first report on menu lost. Are you sure that was a case? We need to program then some kind of guard to prevent menu lose. I hope you can get most of it back from a backup ...

@herrvigg
Copy link
Collaborator Author

Comment by johnclause
Friday Nov 27, 2015 at 19:03 GMT


Let me try to understand the problem again, is below a correct description:

You wish all new pages created on the site to auto-appear in menu regardless how many they are? If many people work on a site, menu will probably have like a 100 pages soon this way. That alone does not sound right to me, I used to think that menu does not change that much dynamically and 100 items in a menu is too much for a normal user. It would think this needs to be re-designed. If you stick with this approach, then your problem is that when people enter just one language on a new page, the menu item gets auto-created, but it is shown only for one language, and you wish it to be shown for all languages.

Is it correct? Once again, it looks awkward to me that menu items will appear in different languages then.

Anyway, I am glad that you figure out the changes needed for you in the code. Maybe one day we will add another option to control how menu items are shown, or if you have time, you may design such an option and submit a pull request with the code needed. Thank you.

@herrvigg
Copy link
Collaborator Author

Comment by cdauth
Saturday Nov 28, 2015 at 14:01 GMT


I don't want the pages to be added to the menu automatically. I just want the menu items to be the same in all languages. So if someone adds a menu item, the item should be listed in the menu in all languages, regardless on whether the page is translated to that language.

Currently, to achieve this, editors have to add the menu item, then scroll all the way up or down in the menu administration, then select another language, scroll back to the menu item, copy in the translated title, scroll back up to select another language and so on (for every language available). This is first of all not very intuitive and most of them will not know or not think of doing that, and second of all it is still a lot of unnecessary steps and prone to forgetting some languages.

I will take care of a pull request soon.

@herrvigg
Copy link
Collaborator Author

Comment by pothos
Sunday Nov 06, 2016 at 22:04 GMT


For me it was enough to comment these two lines out in qtranslate_frontend.php in order to show menu entries in the default language as fallback:

            if(empty($item_title)){
                //qtranxf_dbg_log('removed item: '.$item->title.'; p='.$item->menu_item_parent);
                // <-EDIT: $itemsremoved[$item->ID] = $item;
                // <-EDIT: unset($items[$key]);//remove menu item with empty title for this language
                continue;
            }

@herrvigg
Copy link
Collaborator Author

Comment by lmartins
Wednesday May 17, 2017 at 17:10 GMT


Is there a better approach to this since this was discussed here?

@herrvigg
Copy link
Collaborator Author

Comment by glenndavey83
Friday Oct 06, 2017 at 04:28 GMT


The plugin developer disagrees with people about good ideas, and then disappears forever. That's what happened to this plugin. We on our own.

@dsanti82
Copy link

@herrvigg I'm sorry for that last comment, I can actually say that you are pretty good at being on top of things ;)
But I did wanna comment that I just experienced this same issue. I'll try to explain what happend to me:

  1. Custom Taxonomy - "Destinations" this is a list of Cities (city names don't require translating)
  2. Added each city (not many, like 5 or 6) as sub menu.
  3. When visiting the taxonomy page, the current city I was on was erased from the menu but not the rest.

The above suggestion of commenting those 2 lines worked for me, but thought I should let you know. If I get some time I'll try to come up with a more proper solution than just commenting code lol.

@herrvigg
Copy link
Collaborator Author

No worry, this was not for me 😅

Good you re-visit the issue database, there is still a lot of information that is valid so i did well to bring it back.
Thanks for the update but i will need more time to understand this problem. We'll keep it open for now.

@dsanti82
Copy link

Ohh he referred to the previous devs, phew cool then. Here's a quick vid of what's happening and how you can replicate the error, hope it helps 😄

qtranslatext.mov.zip

@herrvigg
Copy link
Collaborator Author

Follow-up for new feature in #1063.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy issue Legacy issue imported from original repo need info The submitter must provide more info
Projects
None yet
Development

No branches or pull requests

2 participants