• Resolved meischder

    (@meischder)


    Hi,

    I’d like to create a Menubar, for which I can choose between predefined items and a context sensitive list starting with the parent of the current page. Is there a place where I can insert custom code for choosing between the two types in the admin-menu and for creating the actual menu?

    Thanks,

    meischder

    https://wordpress.org/plugins/menubar/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Meischder,

    As you know you can display a menubar with the code

    <?php do_action('wp_menubar','your_menu_name_here'); ?>

    So you could write:

    <?php
    if ( your condition ) do_action('wp_menubar','your_menu_name_here');
    else { your custom code }
    ?>

    You could also try the feature described in this page:

    http://dontdream.it/menubar/the-menubar-php-type/

    Thread Starter meischder

    (@meischder)

    Hi Andrea,

    thanks for your reply.
    Nevertheless my problem is not the choice of the menu, but the use of the optical structure (css etc.) of the created menubar.
    The thing I want is having the option which menu-type (context-sensitive or predefined) when creating one. Depending on your choice you’ll get the normal wpm-admin menu or you don’t. When the user wants a context-sensitive menu I want to build this menu in the existing structure of the plugin. Thus I can change the layout in css for both menus without changing entries in two css-files.
    I’m thinking about a kind of method which returns either the context-menu or forwards the return of the existing methods.

    Thanks,

    meischder

    Plugin Author Andrea Tarantini

    (@dontdream)

    I’m not sure you can do what you need with the existing plugin version.

    What you can do is:

    1. Build two different menus with the same CSS template, and switch between them with PHP code:

    <?php
    if ( choice ) do_action('wp_menubar','first_menu');
    else do_action('wp_menubar','second_menu');
    ?>

    2. Build a menu with dynamic items (PHP type items) and code those items to behave as you need. Examples are in http://dontdream.it/menubar/the-menubar-php-type/

    More complex choices are not supported by the current plugin version.

    Thread Starter meischder

    (@meischder)

    With the first one I only can choose between static predefined menus.
    The second one would be possible. But by using this method I first restrain the number of possible menu items because you can just define n items. Second it is less efficient since I have to put a request to the database for each item and choose the nth entry from this ordered list. Especially if there is actually only one item but 10 predefined items the code runs 10 times.

    So I’m actually looking for the place in the code where the menu is built when loading the page. There I could choose if I want to return a list of predefined menu items or a list of the current siblings.

    Greetings,
    meischder

    Plugin Author Andrea Tarantini

    (@dontdream)

    I didn’t understand you are willing to edit the plugin code. Sorry!

    The menu output happens in the template file, e.g. for the Superfish template it happens in the function wpm_display_Superfish(), file menubar/templates/Superfish/wpm3.php. That function in turn calls the function wpm_out41(), file menubar/wpm-menu.php, that generates the actual menu.

    Hope that helps!

    Thread Starter meischder

    (@meischder)

    Yes that helps.
    Thank you for your effort.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘context sensitive menu’ is closed to new replies.