Not signed in ( Sign In)

Categories

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorpalmito04
    • CommentTimeJan 11th 2010
     permalink
    For "current tab" lovers :D

    I need some help to complete this plugin, with static pages works fine, but with default page no. (Supports menu writen with bbcodes).

    <?php
    /*
    Plugin Name: Almenu
    Version: 0.1
    Plugin URI: http://flatpress.org
    Description: Menu
    Author: palmito04
    Author URI: http://www.digitalinferno.it
    */

    function plugin_almenu_widget() {

    global $fp_params;

    $amenu['subject'] = "AlMenu";
    $amenu['id'] = "widget-plugin-menu";

    $fd=file("fp-plugins/menu/menu.txt");

    $riga=sizeof($fd);

    $tmp="<ul>";

    for($r=0;$r<$riga;$r++) {
    $fd[$r] = apply_filters('the_content', $fd[$r]);
    if ( strstr($fd[$r],$fp_params['page']) == false)
    {$tmp='<li>'.$fd[$r].'</li>';}
    elseif ( strstr($fd[$r],'contact') !== false)
    {$tmp='<li class="active_link">'.$fd[$r].'</li>';}
    else
    {$tmp='<li class="active_link">'.$fd[$r].'</li>';}

    $out.= $tmp;
    }
    $out.="</ul>";

    $amenu['content']=($out);

    return $amenu;

    }

    register_widget('almenu', 'Almenu', 'plugin_almenu_widget');

    ?>

    menu.txt:

    [url=?x]Blog[/url]

    [url=static.php?page=about]About[/url]

    [url=static.php?page=portfolio]Portfolio[/url]

    [url=static.php?page=extra]Extra[/url]

    [url=contact.php]Contact[/url]
    •  
      CommentAuthorpalmito04
    • CommentTimeJan 15th 2010
     permalink
    No one has tested this plugin?
    •  
      CommentAuthorStanley
    • CommentTimeJan 15th 2010
     permalink
    Not yet, but I plan to - I've just done something similar but by adding my own custom menu rather than try to get the fp one to do such things, but I plan to take a look at this. I went my own route because I also wanted sub-menus to appear under each menu option (I have the menu horizontally - like in the inove theme).

    I got it all to work for all types of pages though, so maybe there's something I did which might help you - I'll test your plugin and see how it works. It'd be nice to be able to use a plugin to do the main menu, and it sounds like your plugin nearly does it.
    •  
      CommentAuthorStanley
    • CommentTimeJan 16th 2010 edited
     permalink
    Hmmm... Doesn't seem to be working for me. Here's the page source I get when I go to the contact.php page. There's no active-linkyness to be seen. Also I'm puzzled where the "p" tags have come from, which wrap each list item.

    <div id="widget-plugin-menu">
    <h4>AlMenu</h4>
    <li> <p><a href="http://localhost/flatpress/?x">Blog</a></p>
    </li><li> <p><a href="http://localhost/flatpress/static.php?page=about">About</a></p>
    </li><li> <p><a href="http://localhost/flatpress/static.php?page=portfolio">Portfolio</a></p>
    </li><li> <p><a href="http://localhost/flatpress/static.php?page=extra">Extra</a></p>
    </li><li> <p><a href="http://localhost/flatpress/contact.php">Contact</a>
    </p>
    </li></ul>
    </div>


    The P tags also appear when I navigate to the blog page. They DON'T appear when I open up the "about" static page, but still no active link class shown. Also, I get a widget divider between each menu item.

    <div id="widget-bp-menu">
    <ul>
    <li><a href="http://localhost/flatpress/?">Home</a>
    </li>
    <li><a href="http://localhost/flatpress/?paged=1">Blog</a>
    </li>
    <li><a href="http://localhost/flatpress/static.php?page=about">About</a>
    </li>
    <li><a href="http://localhost/flatpress/contact.php">Contact</a></li>
    </ul>

    </div>


    If it's any help the way I did it was to simply use 2 include files in the header.tpl - one with all the menu items written out in html, e.g.

    <li><a target=_top href="static.php?page=about" class="
    <?php if($thismenusection=="Help About") {
    echo "active";
    }
    ?>">About this site</a></li>

    etc, etc,. I used CSS to style this as a horizontal menu (actually, tabs) which showed as active/inactive as appropriate, with a different sub-menu showing in a row underneath.

    The other include file was the one which did all the donkey-work of figuring out what page the user was on. I called this submenu.inc.php and this went something like this:

    $staticpage = $_GET["page"];

    $file = $_SERVER["SCRIPT_NAME"];
    $break = Explode('/', $file);
    $pfile = $break[count($break) - 1];

    if ($pfile=="index.php")
    {

    switch ($staticpage) // submenus for static pages
    {
    case about:

    $thispagetitle = "About This Site";
    $submenu = $thispagetitle."&nbsp;&raquo;&nbsp;
    <a href='static.php?page=faq'>FAQ</a>&nbsp;&#124;&nbsp;
    <a href='static.php?page=userguide'>User Guide</a>&nbsp;&#124;&nbsp;
    <a href='static.php?page=partners'>Partnerships</a>";
    $thismenusection = "Help About";

    break;
    case faq: // subitem for Help About menu section

    $thispagetitle = "FAQ";
    $submenu = "About This Site&nbsp;&raquo;&nbsp;<b>FAQ</b>&nbsp;&#124;&nbsp;
    <a href='static.php?page=userguide'>User Guide</a>&nbsp;&#124;&nbsp;
    <a href='static.php?page=partners'>Partnerships</a>";
    $thismenusection = "Help About";

    break;
    case userguide: // subitem for Help About menu section

    $thispagetitle = "User Guide";
    $submenu = "About This Site&nbsp;&raquo;&nbsp;
    <a href='static.php?page=faq'>FAQ</a>&nbsp;&#124;&nbsp;<b>User Guide</b>&nbsp;&#124;&nbsp;
    <a href='static.php?page=partners'>Partnerships</a>";
    $thismenusection = "Help About";

    break;
    case partners: // subitem for Help About menu section

    $thispagetitle = "Partners";
    $submenu = "About This Site&nbsp;&raquo;&nbsp;
    <a href='static.php?page=faq'>FAQ</a>;
    $thismenusection = "Help About";

    break;
    case contactus: // subitem for Help About menu section

    $thispagetitle = "Contact Information";
    $submenu = $thispagetitle."&nbsp;&raquo;&nbsp;
    <a href='contact.php'>Contact Form</a>;
    $thismenusection = "Contact Us";

    break;

    default:

    // link to specific blog entry categories here
    $thispagetitle = "&raquo;&nbsp;Start Here";
    $submenu = "Start Here&nbsp;&raquo;&nbsp;
    <a href='?x=cat:100'>Category 1</a>&nbsp;&#124;&nbsp;
    <a href='?x=cat:200'>Category 2</a>&nbsp;&#124;&nbsp;
    <a href='?x=cat:300'>Category 3</a>";
    $thismenusection = "Home";

    }
    }

    if ($pfile=="contact.php") { // submenu for contact page

    $thispagetitle = "Contact Us";
    $submenu = "Contact Us&nbsp;&raquo;&nbsp;<b>Contact Form</b>&nbsp;&#124;&nbsp;
    <a href='send money.php'>Send us some money</a>;
    $thismenusection = "Contact Us";

    }


    It's not pretty but it's effective enough for what I need - and it might give you a few ideas to help you with your plugin.

    Hope this helps you somehow - it'd be nice to get all that kind of functionality built into a nice simple plugin which anyone can use.
    •  
      CommentAuthorStanley
    • CommentTimeJan 16th 2010
     permalink
    Sorry, I had to hack that up a bit ^^^^ to fit the allowed size of the forum comment.