Menu

#108 Pretty admin buttons

open
nobody
None
1
2012-09-07
2006-12-27
No

I just started playing with BlackNova and the first thing I didn't like was the dropdown menu on the main admin page. so I did something about it!

Code added to admin.php:

function buttonmenu($options,$optionname="menu",$action=false)
{
global $swordfish;
if(!is_array($options))
{
echo 'Buttonmenu error: $options is not an array: '. $options;
return false;
}
if(!$action) $action=$_SERVER['PHP_SELF'];
echo "

    \r\n";
    foreach($options as $value => $name)
    {
    echo "
  • \r\n";
    echo " <form action="\"$action\"" method="\"post\"">\r\n";
    echo " <input type="\"hidden\"" name="\"$optionname\"" value="\"$value\"">\r\n";
    echo " <input type="\"hidden\"" name="\"swordfish\"" value="\"$swordfish\"">\r\n";
    echo " <button type="\"submit\"">$name</button>\r\n";
    echo " </form>\r\n";
    echo "
  • \r\n";
    }
    echo "
\r\n";
}

buttonmenu(array(
    'useredit'  =>  '<img src="images/space261_md_blk.gif">User editor',
    'univedit'  =>  '<img src="images/space262_md_blk.gif">Universe editor',
    'sectedit'  =>  '<img src="images/space263_md_blk.gif ">Sector editor',
    'planedit'  =>  '<img src="images/space264_md_blk.gif">Planet editor',
    'linkedit'  =>  '<img src="images/space265_md_blk.gif">Link editor',
    'zoneedit'  =>  '<img src="images/space261_md_blk.gif">Zone editor',
    'ipedit'    =>  '<img src="images/space262_md_blk.gif">IP bans editor',
    'logview'   =>  '<img src="images/uspace.gif">Log Viewer'));

}

Code added to header.php:

.buttonmenu { list-style-type:none;}
.buttonmenu button {width:15em; background-color:#000; border-color:#0066FF; color:#FFFFFF; text-align:left;}
.buttonmenu button img {margin-right:2ex;}

I also too the css section outside of the php tags because that annoyed me. See the file if you don't understand what I mean.

//slightly related: I've used sf.net projects for a long time, but nevercontributed to them before this, so If I'm not doing something quite right, let me know. I intend to submit a good number of other little tweaks before I'm done with blacknova

-Nathan
nathan.friedly - gmail.com

Discussion

  • Nathan Friedly

    Nathan Friedly - 2006-12-27

    updated admin.php + header.php

     
  • Nathan Friedly

    Nathan Friedly - 2006-12-27

    Logged In: YES
    user_id=1677461
    Originator: YES

    "I also too the css section..." should read "I also took the css..." Damn my typing!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.