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?

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

<li><a href={X_SITEURL}user.php>View My Account</a></li>

<li><a href={X_SITEURL}edituser.php>Edit My Account</a></li>

<li><a href={X_SITEURL}viewpmsg.php>Private Messages</a></li>

<li><a href={X_SITEURL}notifications.php>Notifications</a></li>

<li><a href={X_SITEURL}modules/xoopsmembers>Search Members</a></li>

<?php
<{if $xoopsUserIsAdmin}>

echo 
"<li><a href={X_SITEURL}admin.php>Administration</a></li>";
<{/if}>
?>

<li><a href={X_SITEURL}user.php?op=logout>Logout</a></li>

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 "<li><a href='".XOOPS_URL."user.php'>View My Account</a></ li>";

echo "<li><a href='".XOOPS_URL."edituser.php'>Edit My Account</a></ li>";
echo "<li><a href='".XOOPS_URL."viewpmsg.php'>Private Messages</a></ li>";
echo "<li><a href='".XOOPS_URL."notifications.php'>Notifications</a></ li>";
echo "<li><a href='".XOOPS_URL."modules/xoopsmembers'>Search Members</a></ li>";

if ( is_object( $xoopsUser ) && $xoopsUser->isAdmin() )
{
echo "<li><a href='".XOOPS_URL."admin.php'>Administration</a></li>";
}
echo "<li><a href='".XOOPS_URL."user.php?op=logout'>Logout</a></li>";


Login

Who's Online

143 user(s) are online (102 user(s) are browsing Support Forums)


Members: 0


Guests: 143


more...

Donat-O-Meter

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

Latest GitHub Commits