Jump to content

Quick Code Question


TAV1702

Recommended Posts

Hi everyone. I have a quick question if I may.

I have not done very much stuff in the past using echo. I always shyed away from it. I have edited my downloads page in my template I call Crystal 2 to match the admin downloads list.

Now on to my question. I want it to know if it is an admin or a regular user. If it IS an admin I want it to display this info.

<span style="font-size: 8pt">[<a id="dialog" class="jqModal" href="<?php echo SITE_URL?>/admin/action.php/downloads/editcategory?id=<?php echo $category->id?>">Edit</a>] | [<a class="ajaxcall" action="deletecategory" id="<?php echo $category->id?>" href="<?php echo SITE_URL?>/admin/action.php/downloads">Delete</a>] | [<a id="dialog" class="jqModal" 
			href="<?php echo SITE_URL?>/admin/action.php/downloads/adddownload?cat=<?php echo $category->id?>">Add Download</a>]</span>

I know how to make it know if it an admin or not by using

if(Auth::LoggedIn())
{
if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
{ CONTENT WOULD GO HERE }
?>

I have tried several ways to get this to work with no success. Can anyone give me a hand with this? It would really be appreciated. And this code if successful would allow an admin to edit downloads and add without having to go to the admin panel every time. Like If I found a simple typo or something I could fix it right then and there.

Here is my page currently as it sits right now. dloads.jpg

So right next to category name, it would have  [Edit] | [Delete] | [Add Download]

If I figure it out, I will come back and delete or mark this as solved.

Thanks

P.S.  So I'm a dork. This should be moved to Skinning please. Sorry Nabeel

Link to comment
Share on other sites

So you're saying the first code is what you want to display if they have admin permissions... try:

<? if(Auth::LoggedIn())
{
if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
{ echo '
?>
<span style="font-size: 8pt">[<a id="dialog" class="jqModal" href="<?php echo SITE_URL?>/admin/action.php/downloads/editcategory?id=<?php echo $category->id?>">Edit</a>] | [<a class="ajaxcall" action="deletecategory" id="<?php echo $category->id?>" href="<?php echo SITE_URL?>/admin/action.php/downloads">Delete</a>] | [<a id="dialog" class="jqModal" 
			href="<?php echo SITE_URL?>/admin/action.php/downloads/adddownload?cat=<?php echo $category->id?>">Add Download</a>]</span>
<? '; 
} 
} ?>

Link to comment
Share on other sites

Well, I have not messed with it again since I posted this earlier. Been taking care of the baby and all.

What I was wanting to do was make it so that next to each category name for example:

FS9 Fleet  it would checkj my usergroup and if I was an admin it would then show me

FS9 Fleet    [Edit] | [Delete] | [Add Download]  and if I was a regular user (non admin)

it would simply show the category name only.

I tried it the way I originally had it and it worked per the code he gave. The extra pages that were clicked on to edit or add were uglier than ape, but they worked as far as I could tell.

I guess it is just as easy to go to the admin panel. Was just trying to be lazy is all and try something new. Really, I am messing with the code in the system trying new things so I can learn how it all works. I have pulled off a few little stunts on my own so far that have worked out so figured it wouldn't hurt to give this one a try either  ;)

Link to comment
Share on other sites

Yeah I figured it needed the backend after all was said and done. Been tweaking and messing around and I have a really nice looking dowloads list now for the crystal template.  The default one is ok, but the one I did to make it look like that admin list is sweet. Should take a peak at it and consider it. Looks real nice and clean.

Code could use some scrubbing to polish the edges but it is nice.  ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...