[if-admin]..[/if-admin]

Need some help with the script?

[if-admin]..[/if-admin]

Postby Ramon » Wed Jul 25, 2007 3:23 am

I'm working on a comment section and i wondered whether it would be possible to have something like the title suggest. I want whenever an admin makes a comment that the comment has another look, in that way comments from them are better recognized by other users.

I can't use php in templates, at least not the way it is meant to be used so i really need it to be coded into the script.

Something like this:

[if-admin] = <? if($member_group == 'admin') { ?>
[/if-admin] = <? } ?>

Using this in the template allows me to make two different comment styles for normal users and admins. Yet, you would also need the PHP else function in order to stop having a admin reaction twice, once with the "admin" template and once with the "normal" template. So i also need something like this:

[else] = <? else { ?>
[/else] = <? } ?>

Hope i'm not to blurry, kinda hard to explain :P
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby scottdallas » Wed Jul 25, 2007 5:22 am

I get it. It would be sweet. I wonder if you could do the same thing just using the available if-logged code.. cause it's set by user membership levels somewhere somehow so couldn't you somehow trigger what shows per level user? Only super admin would see certain areas.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby FI-DD » Wed Jul 25, 2007 8:04 pm

In inc/show.news.php find this:
Code: Select all
   if (!global_cache){
      if ($is_logged_in and ($member['level'] < 3 or $member['username'] == $row['author'])){
         $cache = str_replace('[if-logged]', '', $cache);
         $cache = str_replace('[/if-logged]', '', $cache);
         $cache = preg_replace('/\[not-logged\](.*?)\[\/not-logged\]/is', '', $cache);
      } else {
         $cache = str_replace('[not-logged]', '', $cache);
         $cache = str_replace('[/not-logged]', '', $cache);
         $cache = preg_replace('/\[if-logged\](.*?)\[\/if-logged\]/is', '', $cache);
      }
   }


and add below:
Code: Select all
   if (!global_cache){
      if ($is_logged_in and ($member['level'] == 1)){
         $cache = str_replace('[if-admin]', '', $cache);
         $cache = str_replace('[/if-admin]', '', $cache);
         $cache = preg_replace('/\[not-admin\](.*?)\[\/not-admin\]/is', '', $cache);
      } else {
         $cache = str_replace('[not-admin]', '', $cache);
         $cache = str_replace('[/not-admin]', '', $cache);
         $cache = preg_replace('/\[if-admin\](.*?)\[\/if-admin\]/is', '', $cache);
      }
   }

Now you should be able to use [if-admin] and [not-admin] in your template.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Ramon » Thu Jul 26, 2007 11:59 pm

I think you meant that show.comment.php right? Well i've put the code in both show.comment.php and show.news.php but it doesn't work. Just shows admin comments as regular user comments.
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby FI-DD » Tue Jul 31, 2007 8:10 pm

Right, my post was stupid.

Try this:

1. Open head.php and find this:
Code: Select all
$members[] = $row;


add below:
Code: Select all
$member_details[$row['username']] = $row;


2. Open inc/show.comments.php and find this:
Code: Select all
      $output = str_replace('{id}', $id, $output);


add above:
Code: Select all
      if($member_details[$row['author']]['level'] == 1){
         $output = str_replace('[if-admin]', '', $output);
         $output = str_replace('[/if-admin]', '', $output);
         $output = preg_replace('/\[not-admin\](.*?)\[\/not-admin\]/is', '', $output);
      }
      else{
         $output = str_replace('[not-admin]', '', $output);
         $output = str_replace('[/not-admin]', '', $output);
         $output = preg_replace('/\[if-admin\](.*?)\[\/if-admin\]/is', '', $output);
      }

Now you should be able to use [if-admin] and [not-admin] in your template.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby scottdallas » Wed Aug 01, 2007 12:14 am

Well that's a fun little extra. I'm changing my code to that.

Hey.. if you can do that delete button would be fantastic for spam control. How do I generate the URL that is in the newsletter for delete comment? That would be perfect.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby FI-DD » Wed Aug 01, 2007 6:04 pm

scottdallas wrote:Hey.. if you can do that delete button would be fantastic for spam control. How do I generate the URL that is in the newsletter for delete comment? That would be perfect.

Huh, what button are you talking about?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby scottdallas » Wed Aug 01, 2007 11:33 pm

I'm sorry.. I didn't mean the newsletter.. I meant when you put your email in 'System Settings' and it mails you notifications for new comments.. and it includes the 'delete' link.
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Postby FI-DD » Tue Aug 07, 2007 6:49 pm

Check the default template - comment section. There's already this link to delete comments:
Code: Select all
<a href="{cutepath}/index.php?mod=editcomments&amp;action=dodeletecomment&amp;newsid={id}&amp;delcomid[]={comment-id}&amp;deletecomment=yes" target="_blank" title="Delete comments" style="color: #ccc;">Delete</a>
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Disharmony » Tue Jun 24, 2008 7:52 pm

Looks like this is almost exactly what I'm looking for. How do I make it look like this though?

Image

I want author.gif to show up below the username as well as give the username a different font color in bold italics.
Disharmony
 
Posts: 45
Joined: Thu Jun 05, 2008 12:45 pm

Postby typeman » Wed Dec 30, 2009 7:58 pm

Sorry to revive an old topic, but I cant seem to get this to work.

I've done exactly as it said above, but with no luck. [if-admin]...[/if-admin] isn't appearing on my templates and when I put it inot my templates, it simply just said [if-admin]etc[/if-admin].

Can anyone help? :)

Thanks in advance! :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby typeman » Thu Dec 31, 2009 10:16 am

I dont know why but it's working now :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am


Return to Help



Who is online

Users browsing this forum: No registered users and 0 guests

cron