Not logged in. · Lost password · Register
Forum: General Help and Support Development RSS
templates and the new menu-system
Avatar
meanddokuwiki #1
Member for 2 months · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: templates and the new menu-system
Hello,
I need some help with template and the new menusystem. I searched in the forum but couldn´t find find an answer. Even actual templates (besides the dokuwiki-template) use the old  tpl_ functions …
The dokuwiki-template uses the the following code for the page-actions menu:

<!-- PAGE ACTIONS -->
            <div id="dokuwiki__pagetools">
                <h3 class="a11y"><?php echo $lang['page_tools']; ?></h3>
                <div class="tools">
                    <ul>
                        <?php echo (new \dokuwiki\Menu\PageMenu())->getListItems(); ?>
                    </ul>
                </div>
            </div>

Ok. Now I want to add a new but existing menuitem/button to it, lets say the Media-manager. The former way was to use the tpl_ … functions:

<!-- PAGE ACTIONS -->
            <div id="dokuwiki__pagetools">
                <h3 class="a11y"><?php echo $lang['page_tools']; ?></h3>
                <div class="tools">
                    <ul>
                        <?php echo (new \dokuwiki\Menu\PageMenu())->getListItems(); ?>

<?php tpl_toolsevent('usertools', array(                                 'media'     => tpl_action('media', 1, 'li', 1,'<span>', '</span> <img src='.tpl_basedir().'images/pagetools/11_mediamanager.png width="35px" height="35px" ')
)); ?>

                    </ul>
                </div>
            </div>

It is working ok right now, but it gives a warning that its depreceated. How this is done in the new menusystem? Do I need to write a plugin for that or can it be achieved with a template only?

Thanks for any hints
Avatar
schplurtz (Moderator) #2
Member since Nov 2009 · 329 posts · Location: France, Finistère
Group memberships: Global Moderators, Members
Show profile · Link to this post
Hi,

As you've already discovered, not all templates (very few ?) currently use this new menusystem. We can only hope that actively maintained templates will switch to this system. So, depending on your template, you have to edit the template files or use the menu system.

It is working ok right now, but it gives a warning that its depreceated. How this is done in the new menusystem? Do I need to write a plugin for that or can it be achieved with a template only?
With the menu system, you need to create an action plugin that handles the MENU_ITEMS_ASSEMBLY event. The upside is that you only have to do this once; when you update DokuWiki, your button will still be there.

If you've never written a plugin before, take a look at https://www.dokuwiki.org/devel:plugins, there is, among other things, a link to a plugin wizard that will create a skeleton code. The example links in the MENU_ITEMS_ASSEMBLY page are very helpful.
http://schplurtz.free.fr/wiki/
Avatar
andi (Administrator) #3
User title: splitbrain
Member since May 2006 · 3370 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
As schplurtz said, if you want to modify menu contents you need to handle the appropriate action hook. However it is possible to do that from your template's code - no need to have a separate plugin. I recently implemented that in this template:

https://github.com/OpenSchulportfolio/dokuwiki-template-po…

Check the Template class and it's constructor for the hook registration.
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-01-17, 20:30:46 (UTC +01:00)