Problem:
Sitemap generation would only work for the current language - other languages would be incomplete or contain links to the wrong nodes.
Steps to reproduce;
1. Install Drupal 7, i18n and xmlsitemap.
2. Set up multiple languages, create some translated nodes with custom paths.
3. Set up a menu - set the menu translation mode to "Translate and Localize"
4. Create menu items for different languages, to the various different nodes.
5. On the front end, the menu will only show items that match the current language - so you can swap out menu items for specific languages.
6. Create a sitemap for each language.
7. Run Cron. The site map for the current language will populate correctly, other languages will display incorrect links, and without their aliases.
I tracked the problem down the xmlsitemap_menu_create_link function.
This was looking for the menu item's language in the wrong place, so all menu items were given "language undefined" UND.
Also the way that the menu works in "Translate and Localize" mode is that when the menu is displayed, any menu items that don't match the current language (or are language neutral) are hidden. This causes all other links to be set as inaccessible in the xmlsitemap table.
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | Screen Shot 2016-03-09 at 4.22.44 PM.png | 54.9 KB | RavindraSingh |
| #20 | xmlsitemap_menu-1966512-17.patch | 1.29 KB | jyraya |
Comments
Comment #1
silloyd commentedPatch attached that fixes the issue for me.
Comment #2
ludo.rThis patch works perfectly for me.
My menus are set to " Fixed Language".
Comment #3.0
(not verified) commentededit
Comment #4
tolasam commented1: xmlsitemap-1966512.patch queued for re-testing.
Comment #6
dr.osd commentedSame problem. Appliyng patch missing node/xx and taxonomy/xx path links from sitemap.xml in not base language.
Comment #7
vladan.me commentedThis patch actually should fix both issues mentioned in XML generation process
+ $menu_item['xmlsitemap']['access'] = $menu_item['access'] && !$menu_item['external'];This allows menus that are wrongly interpreted as hidden (i18n issue) to be visible.
This sets appropriate language of the menu item so it gets set well while generating links and figuring out if menu should be visible or not.
Rolling the same patch.
Comment #8
vladan.me commentedProbably needs some additional tests since nothing fails.
Comment #9
simon georges commentedI can confirm it's much better with the patch than without (unfortunately, still not perfect, but much much better).
Comment #10
simon georges commentedNevermind, I had an issue with the data of my menu.
I can confirm my sitemaps now exactly match the status of the menus and the languages. Thanks a lot for the patch, this is really needed for websites with i18n.
Comment #11
giupenni commentedWorks like a charm.
Thank you.
Comment #12
simon georges commentedOk, I think that qualifies as several reviews ;-)
Comment #13
dave reidIf I wasn't using i18n, what affect does removing the check on $item['hidden'] have? Do we know the side effects of that change?
Comment #14
jyraya commentedI agree with Dave Reid, removing simply $item['hidden'] is not the best solution because what do we do if the menu link is actually hidden?
After debugging the full process determining the value of 'hidden', I observed that "xmlsitempap_menu" use "menu_link_load" function to load the menu link.
Before returning the menu item, it translates it.
In my environment but I think it is also the case in yours, "I18N menu" alters this translation process by, amongst other actions, forcing the attribute 'hidden' to TRUE if the menu link language does equal to "LANGUAGE_NONE" ("und") or to the interface language.
So to solve the problem, I see so far 2 possibilities:
In my opinion, the 2nd possibility is the easiest one to implement. The patch "xmlsitemap_menu-1966512-14.patch" could be an implementation.
Comment #15
jyraya commentedComment #17
jyraya commentedNew version, I will not meet EOL problems this time.
Comment #18
jyraya commentedComment #20
jyraya commentedLast try.
Comment #21
justb3a commented#20 works for me. Thanks!
Comment #22
steveoriol#20 works for me. Thanks!
Comment #23
alvar0hurtad0yes, it works.
Comment #24
RavindraSingh commentedReopening it, as this is not working with 7.x-2.2 release.
It is still adding duplicate and adding node/nid URLs.
Comment #25
dave reidThis should be going inside the xmlsitemap_i18n submodule to alter the default link values generated by xmlsitemap_menu. xmlsitemap_menu should know *nothing* about i18n and should only support what core supports.
Comment #26
RavindraSingh commentedNope, it looks like when nodes are getting duplicate from the xmlsitemap_node submodule.
Comment #27
crtlf commentedPatch #20 works for me, with 7.x-2.3 release.
Thanks !
Comment #28
mmncs commented#20 with 7.x-2.3, works for me as well.
Many thanks!
Comment #29
pifagorComment #31
rescandon commented#20 with 2.5 has been working very well in one of our clients in the last two years.
Thank you.