Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   How To Add AdminCP Link To Sidebar (http://www.mysidiaadoptables.com/forum/showthread.php?t=5184)

parayna 09-04-2016 04:35 PM

How To Add AdminCP Link To Sidebar
 
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 Code:

<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 Code:

   {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">{$messagesMessages</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!

Dinocanid 09-04-2016 07:10 PM

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

Quote:

if($mysidia->user instanceof Admin){
$adminCP = new Link("admincp/", FALSE, FALSE);
$adminCP->setText("Admin Control Panel");
$adminCP->setListed(TRUE);
$linksList->add($adminCP);

parayna 09-05-2016 11:28 AM

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!

Hall of Famer 09-05-2016 12:14 PM

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.

parayna 09-05-2016 01:03 PM

I did it! :D I opened class_template and put this in:

PHP Code:

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

And then put:

PHP Code:

{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


All times are GMT -5. The time now is 07:47 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.