1
khuhner
Conditional Code for "Administration Menu Link"
  • 2006/2/2 23:16

  • khuhner

  • Quite a regular

  • Posts: 232

  • Since: 2006/1/6 3


I have a custom built block where I have inserted the 'user' type functions (View Account, Edit Account, etc.). I have added the Administration link, however I'd like to wrap it in conditional code so the menu only appears if the current user IS an Administrator.

I have tried numerous approaches and cant seem to find the right one. My latest code is below. Can anyone assist?

include("../../mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");
$xoopsOption['show_rblock'] = 1;
?>

  • View My Account


  • Edit My Account


  • Private Messages


  • Notifications


  • Search Members


  • <{if $xoopsUserIsAdmin}>

    echo 
    "
  • Administration
  • "
    ;
    <{/if}>
    ?>

  • Logout

  • 2
    Bender
    Re: Conditional Code for "Administration Menu Link"
    • 2006/2/2 23:30

    • Bender

    • Home away from home

    • Posts: 1899

    • Since: 2003/3/10


    Did you try the version described at the end of this thread:

    If XOOPS is admin? ?
    Sorry, this signature is experiencing technical difficulties. We will return you to the sheduled signature as soon as possible ...

    3
    khuhner
    Re: Conditional Code for "Administration Menu Link"
    • 2006/2/2 23:46

    • khuhner

    • Quite a regular

    • Posts: 232

    • Since: 2006/1/6 3


    Thanks for the quick response! I read (and reread) this thread. It seems as if people are "trying this and that." I cant see a clear answer....?

    I created a custom block using the Admin interface (I copied all the code from the block into my post above).
    I have it set to HTML type. I just want to have a few links in it....nothing "fancy!"

    I must be doing something very silly here...

    4
    tripmon
    Re: Conditional Code for "Administration Menu Link"
    • 2006/2/3 0:08

    • tripmon

    • Module Developer

    • Posts: 462

    • Since: 2004/2/28


    set 'type' to PHP script

    5
    khuhner
    Re: Conditional Code for "Administration Menu Link"
    • 2006/2/3 1:04

    • khuhner

    • Quite a regular

    • Posts: 232

    • Since: 2006/1/6 3


    All-

    Thanks for the input! Putting together ideas from this thread, the other linked thread and trial-and-error, here is the code. I had to add 'echo' statements, and it took 30 minutes to see the single tick after the "href="!!!

    Thanks again,
    Kurt




    Quote:

    global $xoopsUser;
    echo "
  • View My Account";

    echo "
  • Edit My Account";
    echo "
  • Private Messages";
    echo "
  • Notifications";
    echo "
  • Search Members";

    if ( is_object( $xoopsUser ) && $xoopsUser->isAdmin() )
    {
    echo "
  • Administration
  • ";
    }
    echo "
  • Logout
  • ";


    Login

    Who's Online

    264 user(s) are online (223 user(s) are browsing Support Forums)


    Members: 0


    Guests: 264


    more...

    Donat-O-Meter

    Stats
    Goal: $100.00
    Due Date: Nov 30
    Gross Amount: $0.00
    Net Balance: $0.00
    Left to go: $100.00
    Make donations with PayPal!

    Latest GitHub Commits