Problem/Motivation
The problem that I faced was that after migrating from version 1.x to 2.x there were some missing CSS classes on which my theme was relying for styling the menu items.
In version 1.x inside the buildForSitemap function there was a $class variable which sets several classes, which are not present in the 2.x version.
Proposed resolution
I have created a patch, which adds the missing classes, but without the "first" and "last" classes, which are not needed for me.
Remaining tasks
Write a patch- done by @divanova in #2Add a test- done by @tom konda by #7Review and feedback- done by @mparker17 in #8RTBC and feedback- done by @mparker17 in #8Commit- done by @mparker17 in #9Release- released in 8.x-2.4
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|
Issue fork sitemap-3400050
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
divanova commentedComment #3
mparker17@divanova, thank you very much for the contributon; and thank you for your patience with me!
This patch looks great: the only thing that's preventing me from merging it is automated tests. I need automated tests, because I don't want future changes to the sitemap module to break this functionality, and break your website as a result!
I think you could do this by modifying
\Drupal\Tests\sitemap\Functional\SitemapMenuTest::testMenus()to include some more assertions. For example, the following checks for an "expanded" class on an HTML <a> tag with the link text$node_1_title...... note that example might not work (because I haven't checked it with the patch applied)... you'll have to look closer at the code in
\Drupal\Tests\sitemap\Functional\SitemapMenuTestto see what it's supposed to do. You may also have to look at the the PHPUnit output files ("artifacts") to see what actually happens in the test environment.Thank you again!
Comment #4
mparker17Comment #7
tom kondaReroll patch #2 and add PHPUnit test.
Comment #8
mparker17Thanks @tom konda!
This looks good to me! Manual testing shows this working well.
I couldn't get the
active-trailclass to display, even when I put the sitemap in a menu being output onto the sitemap - but the code to detect the active-trail existed before this patch (I think it's likely that I've set up my test site wrong) - I don't see any reason to hold back this change.Comment #10
mparker17Merged! Thanks everyone!
I'll look into making a release with these changes in the next few weeks! (I'm hoping to merge #3545794: Remove unused cache, max_age configuration options in SitemapSyndicateBlock and #3545858: Migrate sitemap.settings.rss_front to SitemapSyndicateBlock's configuration; test, deprecate SitemapSyndicateBlock before making a release)
Comment #13
mparker17I've released this change in version 8.x-2.4!