====== MenuExt Plugin ====== ---- plugin ---- description: Add arbitrary links in DokuWiki menus author : Andreas Gohr email : dokuwiki@cosmocode.de type : action lastupdate : 2021-07-29 compatible : Hogfather, Igor depends : conflicts : similar : tags : menu downloadurl: https://github.com/cosmocode/dokuwiki-plugin-menuext/zipball/master bugtracker : https://github.com/cosmocode/dokuwiki-plugin-menuext/issues sourcerepo : https://github.com/cosmocode/dokuwiki-plugin-menuext/ donationurl: screenshot_img : ---- This plugin allows Wiki administrators to add arbitrary links into DokuWiki's [[devel:menus|Menus]] by editing a simple configuration file. ===== Installation ===== Install the plugin using the [[plugin:plugin|Plugin Manager]] and the download URL above, which points to latest version of the plugin. Refer to [[:Plugins]] on how to install plugins manually. ===== Configuration ===== To make use of the plugin, you need to create a ''[DOKUWIKI'S ROOT]/conf/menuext.json'' (not in the plugin's directory). Here's the example that comes with the plugin: { "page": [ { "order": 3, "label": { "en": "Google Search", "de": "Google Suche" }, "title": { "en": "Execute a Google search on the current page ID", "de": "Führe eine Google Suche mit der aktuellen Seiten-ID aus" }, "link": "https://www.google.com/search?q=@ID@", "svg": "google.svg", "attr": { "target": "_blank" } }, { "action": "login" }, { "classname": "\\dokuwiki\\plugin\\dw2pdf\\MenuItem" } ] } As you can see, it's a nested structure configuring the menu items. The top level defines the menu to add to (see [[devel:menus#Available Menus]]) For each you can define the items to add. | order | Position to add this item (starts at 0). Defaults to to add at the end. Use negative numbers to count from the end | | label | The label to show on the menu item. One entry per language. | | title | The title to show on mouseover. One entry per language. | | link | The link to use when clicking the item, can contain [[:namespace_templates#Replacement Patterns]] | | svg | The SVG icon to use. Can be a media ID, an absolute file name or a icon from [[https://materialdesignicons.com/|materialdesignicons.com]] (auto downloaded from the latter) | | attr | additional attributes to set on the A node in HTML | Alternatively to creating custom items, you can also reuse existing items by specifying the ''action'' or ''classname'' parameters. Above example adds the login/logout button and PDF export button to the page menu. The second example is redundant in case of page menu (it will double the PDF button), but it demonstrates how to add items supplied by plugins. | order | Position to add this item (starts at 0). Defaults to to add at the end. Use negative numbers to count from the end | | action | A standard action (see [[devel:action_modes]]). Please note that not all actions do have corresponding MenuItems available | | classname | Fully qualified class name of a menu item created by a plugin, meaning a class extending ''dokuwiki\Menu\Item\AbstractItem'' | ===== Javascript ===== You can attach Javascript to your items by specifying the function to be called on click: "attr": { "onclick": "hello()" } Remember, you are in global scope, so your method must be available there.