ProfessionalWiki / chameleon

Provides a highly flexible and customizable skin using Bootstrap 4
https://www.mediawiki.org/wiki/Skin:Chameleon
Other
115 stars 63 forks source link

Add options to NavMenu to include/exclude specific sections. #358

Closed mdoggydog closed 1 year ago

mdoggydog commented 1 year ago

This commit adds new include and exclude attributes to the NavMenu component. Both are intended to hold semicolon-separated lists of menu section names. If neither is specified, the behavior is unchanged from the current behavior. If include is provided, only the specified sections from the sidebar are processed. If exclude is provided, the specified sections are skipped.

These options are complementary, and allow one to locate different menu sections in different NavMenu instances, e.g., in different locations on the page.

mdoggydog commented 1 year ago

FYI, the original motivation behind this PR was that I wanted to add tooltips (title attributes) to nav-links created by the Menu component. It looked like it was going to be a pain, to pass another parameter up through a chain of methods in many different places in MenuFromLines.php, etc....

At some point it occurred to me that NavMenu already does pretty much everything that Menu does, and more (e.g., tooltips and access-keys) all in the "standard" MediaWiki way, by sticking everything in MediaWiki:Sidebar. The only thing missing was the ability to be selective about which chunks of Sidebar would be rendered in which areas of the UI. (NavMenu has no mechanism for assigning extra classes to individual items like Menu does, but with the awesome power of the SCSS customization, this is not really necessary.)

Again, apologies for the lack of unit-tests.