Hi,

I have enabled xmlsitemap for a Menu. Menu items got generated in sitemap.xml file. But there were child items for the menu, which were not generated in the xml file. Does the module only supports the Menu items only for first level items ?
Please advise

Thanks,
Harysh

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

harysh created an issue. See original summary.

elimw’s picture

Version: 8.x-2.12 » 8.x-2.x-dev
Status: Active » Needs review
FileSize
2.24 KB

Here's a patch I've created which recursively gets child menu links.

gbyte’s picture

Thank you @elimw, looks clean and I will test it in the coming days. Would you mind creating another issue for 3.x and porting your patch? Should only be some minor differences to 2.x.

  • gbyte.co committed 425e0ee on 8.x-2.x authored by elimw
    Issue #2974760 by elimw, harysh, gbyte.co: Menu child items are not...

  • gbyte.co committed dbc425d on 8.x-3.x authored by elimw
    Issue #2974760 by elimw, gbyte.co: Menu child items are not generated
    
gbyte’s picture

Status: Needs review » Fixed

Fixed both in 2.x and 3.x Thanks!

harysh’s picture

Thank you @elimw for the patch, child items are now listed in the xml file.

gbyte’s picture

@harysh The has been already committed to the development version of the module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

agoradesign’s picture

I haven't seen that this is already fixed. My solution that I was close to post here as patch would have been a one liner -> you could have added this menu tree transform call: ['callable' => 'menu.default_tree_manipulators:flatten']

ending up in ->

  $tree = $menu_tree->transform($tree, [
    ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
    ['callable' => 'menu.default_tree_manipulators:flatten']
  ]);
agoradesign’s picture

Anyway, a new tagged release would be great, because this is really an important bugfix

gbyte’s picture

@agoradesign Interesting, would you mind creating a patch for current 2.x dev so we can run tests through it? If we can do this with a one liner, we should.

agoradesign’s picture

ok, here's the patch, reverting the commit and adding the flatten tree manipulator.

I've only tried this solution once yesterday and it seemed to work like a charm. After I saw this already committed fix, I've switched to that version though.

PS: I cannot reopen the issue

gbyte’s picture

Component: Miscellaneous » Code
Status: Closed (fixed) » Needs review

  • gbyte.co committed fb255e3 on 8.x-3.x
    Issue #2974760 by agoradesign, gbyte.co: Clean up menu link generator...
gbyte’s picture

Status: Needs review » Fixed

Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.