Ina Code Blog

bunch of code in one place
« Flexible upload of images for Wordpress
Cforms II plugin for Wordpress »


Nov
11

Sticky menu plugin for Wordpress

Posted by admin in wordpress

Have you ever try to create more complex web page with Wordpress? If yes, then you probably came accross problem with menu’s as Wordpress creates them automaticaly. With Sticky menu plugin you can create as many custom menu’s as you need and put them exactly where you need it. And it’s very easy to use!

  1. Download the plugin: sticky_menu.zip
  2. Unzip and upload the folder to your plugin folder (usually: /wp-content/plugins/).
  3. Activate the plugin.
  4. Go to ‘Manage -> Sticky Menu’ and create your custom menu.
  5. Insert the following code to your theme files where you want the created menu to aprear (index.php, archive.php):

    $menu = new stickymenu;
    $menu->display_menu(’menu=Main’); //Display’s menu named ‘Main’

Plugin’s homepage.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

9 Responses to “Sticky menu plugin for Wordpress”

  1. Added by admin on Feb at 6

    I find this plugin very usefull, but I needed it to show which menu item is active. So I posted a trouble ticket at plugin’s homepage, but didn’t get an answer. So I digged in and found the solution:

    1. Open file /wp-content/plugins/stickymenu/stickymenu.php
    2. Find:

      function display_menu($args = ”)

      and add above:

      // Ignores page_on_front. Internal use only.
      function get_page_link2( $id = false ) {
        global $post, $wp_rewrite;
        if ( !$id )
          $id = (int) $post->ID;
        $pagestruct = $wp_rewrite->get_page_permastruct();
        if ( ” != $pagestruct && ‘draft’ != $post->post_status ) {
          $link = get_page_uri($id);
          $link = str_replace(’%pagename%’, $link, $pagestruct);
          $link = user_trailingslashit($link, ‘page’);
        } else {
          $link = “page_id=$id”;
        }
        return $link; //apply_filters( ‘_get_page_link’, $link, $id );
      }

    3. Find:

        foreach($menu_items as $item) {
          $output .= ‘<li’ . (($item[’class’])? ‘ class=”‘.$item[’class’].’”‘ : ”) . ‘><a href=”‘.$item[’link’].’” title=”‘.$item[’name’].’” rel=”nofollow”>’.$item[’name’].’</a></li>’.”\n”;
        };

      and replace it with:

      foreach($menu_items as $item) {
        if (strstr($item[’link’], $this->get_page_link2()))
          $item[’class’] .= $item[’class’] == “” ? “active_menu” : ” active_menu”;
          $output .= ‘<li’ . (($item[’class’])? ‘ class=”‘.$item[’class’].’”‘ : ”) . ‘><a href=”‘.$item[’link’].’” title=”‘.$item[’name’].’” rel=”nofollow”>’.$item[’name’].$ok.’</a></li>’.”\n”;
        };

    4. In theme style.css define class .active_menu as you would like active menu item to appear.

    And that’s it!

  2. Added by jurek on Mar at 14

    Please, I cannot find this:
    // Ignores page_on_front. Internal use only.
    function get_page_link2( $id = false ) {
    global $post, $wp_rewrite;
    if ( !$id )
    I think that You have inside zip quite new version sticky menu. Pity..

  3. Added by jurek on Mar at 14

    OK, I catch it but it print error:
    Warning: strstr() [function.strstr]: Empty delimiter in …/wordpress/wp-content/plugins/stickymenu/stickymenu.php on line 105

  4. Added by jurek on Mar at 14

    Sorry, I’m back down, probably I’m too stipid for this… Can You share you stickymenus?

  5. Added by admin on Mar at 17

    Hi Jurek,
    maybe there was a problem closing the get_page_link2 function. It’s hard to say without seeing the code … So, here is my stickymenu.php (not full plugin, just overwrite your stickymenu.php file).
    I hope that helps.

  6. Added by jurek on Mar at 19

    Hi, thanks a lot for php, but now I undrestood that it cant works, because some of subpage is currently completely other page, merged by one header! Look at my adress on home or linki and gallery, there are different!

    Thanks a lot for help!

  7. Added by admin on Mar at 20

    Hi Jurek,
    aha I understand what you mean. You could still use the plugin for /wordpress/ pages, just add ../zenphoto/ for Galeia link.
    On your Galeria page you can’t use the plugin because it’s not part of wordpress, so you probably made the menu by hand. If you want you can play a little and get sticky menu plugin to work on wordpress pages :)
    bby

  8. Added by Les Booth on Mar at 20

    I left a comment on the publisher’s page for Sticky Menu and I’m doing so here as well: same topic. Why?

    Either I don’t fully understand the way the SM plug-in works or I’m doing something wrong (entirely possible on both accounts!), but I don’t see the need for SM.

    I can build a ‘text box’ widget to construct a custom menu in about the same amount of time it takes to build the SM.

    So Why use it? Does it do something I’m not seeing. I’ve never gotten it to work correctly either.

    As well, you say to add the code to index and archive files, while the publisher says the header, sidebar and footer files. ?? I’ve tried both; the publisher’s makes more sense; but I’ve never gotten either to work.

    I’m open minded - convince me I need to use this - or explain what SM is really trying to do different than the ‘text box’ widget mentioned above.

    Thanks

    net500cg

  9. Added by admin on Mar at 20

    Hi Les Booth,
    yes, menus are usualy placed in sidebar, header or footer, but in my case sidebar contained pool, mailinglist and some other stuff which are always visible.

    I used horizontal main menu and several vertical submenus which I placed on index and archives files. So where you place the menu is up to you and your needs. I used Sticky menu plugin because I had 5 different submenus and each is shown on some specific pages. One submenu is not shown all the time, just on some pages.

    If you can solve your menu problem with text box then good for you, but it was not working for my problem, so I found this plugin and it was just what I needed and it worked fine the first time I used it.

    Everybody has specific needs for their page and there are many options for solving them, so use what suits you best.

    I’m not trying to convince you into anything, I just share my experience and hopefully someone finds it helpfull.

    Good luck!

Leave a Reply

Comment