How To Add AdminCP Link To Sidebar

Forum
Last Post
Threads / Messages

KittHaven

Member
Member
Joined
May 21, 2013
Messages
478
Points
28
Age
25
Location
Devon, UK
Mysidian Dollar
8,292
I'm using a smarty built sidebar that is created using the themes template.tpl file. What do I need to add to have the Admin Control Panel link only visible to admins? A bit like it is if you are using the normal method of having the sidebar. I have tried figuring it out but I can't XD All I have so far is this:

PHP:
<a href="{$home}admincp">Admin Control Panel</a>

And this is my whole file if anyone wants to see the way it is laid out:

PHP:
   {include file="{$root}{$temp}{$theme}/header.tpl"}

<body>
<div id="wrapper">
<table cellspacing="3px" cellpadding="0px">
<tr><td colspan="2" id="image"><span><center><a href="{$path}index">{$site_name}</a></center></span></td></tr>
<tr><th colspan="2">{$menu}</th></tr>
<tr><td id="menu">
<b><p><u>{$smarty.now|date_format},
{$smarty.now|date_format:"%I:%M %p"}</u></p></b>
{if $logged_in}
<br><br><br><br><br><p><b>You are logged in as:</b></p>
<a href="{$home}profile/view/{$username}"><font size="4"><b>{$username}</b></font></a>
<p>{$avatar}</p>
<p>You have <i>{$cash} {$mysidia->settings->cost}</i>Credits!</p>
<a href="{$home}messages">{$messages} Messages</a>
<a href="{$home}login/logout">Log Out</a>
<a href="{$home}admincp">Admin Control Panel</a>{/if}
<br><br>
<br>{$sidebar}
<a href="{$home}online">{$online}</a><br><br>	 

</td><td id="content">
<h1>{$document_title}</h1>
<p>{$document_content}</p>

</td></tr>
<tr><td colspan="2" id="footer">{$footer}</td></tr>
</table>
</div>

</body>

</html>

Thank you!
 
There's this block of code from class_sidebar.php:

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);
 
I suppose that's a step in the right direction XD I need to figure out what to input so it can be in the template.tpl file... that just displays as text (might as well try it, eh? XD) and I need the code to somehow say 'if user is admin/uid=1, show this text'... I'm a bit lost still though XD I've tried a few things, but no luck so far!
 
Mysidia only uses smarty templates for the basic layout, it generates html contents using GUI objects. Its possible to do what you want by assigning smarty template variables, such as $isAdmin, which is the boolean value of ($mysidia->user instanceof Admin). It may be a bit complex for you though.
 
I did it! :D I opened class_template and put this in:

PHP:
$this->assign("isAdmin",$mysidia->user instanceof Admin);

And then put:

PHP:
{if $isAdmin}<a href="{$home}admincp">Admin Control Panel</a>{/if}

I can't believe it worked >.> I logged in with the second account I have as a normal member and the link wasn't there. So proud of myself right now T-T I was winging it... XD
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,129
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top