News:

SMF 2.0.19 has been released! Please update. Read more.

Main Menu

Group Images Instead of Names

Started by Scareface, June 12, 2013, 11:28:34 PM

Previous topic - Next topic

Scareface

Hey guys, this is a simple trick to display group images. This method does not involve adding the image directly in the name. If you add an image in the group name, it messes up the whole forum. so this method doesn't cause any error and you can use this method anywhere. Now I will show how to use this in display template,

Previews:







  • Go to your display.template.php
  • Find this code
    Quote<li class="membergroup">', $message['member']['group'], '</li>
  • Repace it with
    Quote<li class="membergroup"><img src="http://YourDomainName.com/ranks/', $message['member']['group_id'], '.png"> </li>
  • Now create a directory called "ranks" in your forum root.
  • You need to get group id for each group from the admin panel. For eg admin group is 1 so the image will be 1.png
  • Upload all the images.
  • Done.


Now, this only appears in posts but you can also make it to appear in profiles and other pages using this simple edit.

kat

As this is a tip/trick, mind if I move it to the... er... "Tips and tricks" board?

Scareface

Quote from: [email protected] on June 13, 2013, 07:21:24 AM
As this is a tip/trick, mind if I move it to the... er... "Tips and tricks" board?

Sure.


Burke ♞ Knight

Just what do you edit for the Profile page to show right?
I got the display and private message pages done. :)

Scareface

Profile.template.php. Edit there to display images in profiles.

Burke ♞ Knight

I looked there and did not find the code you showed.
Do you have the exact line to find and replace with?

Scareface

Quote from: BurkeKnight on June 22, 2013, 10:07:03 PM
I looked there and did not find the code you showed.
Do you have the exact line to find and replace with?

This needs a little modification to be done.

Find this.

<span class="position">', (!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']), '</span>

Replace with

<img src="http://YOURWEBSITE.com/ranks/', $context['member']['group_id'], '.png">

Burke ♞ Knight

Thank you very much, my friend.
I've been so backlogged, I'm just now getting around to going through emails from 2008....LOL
Worked perfectly. :)


P.S. You really should make this a mod.

Scareface

Quote from: BurkeKnight on June 22, 2013, 11:38:31 PM
Thank you very much, my friend.
I've been so backlogged, I'm just now getting around to going through emails from 2008....LOL
Worked perfectly. :)


P.S. You really should make this a mod.

This is just 1 line coding, so can be easily edited :)

Burke ♞ Knight

I was just thinking for those people with about 3-4 or more sites.... LOL :P

Scareface

Quote from: BurkeKnight on June 23, 2013, 06:12:07 AM
I was just thinking for those people with about 3-4 or more sites.... LOL :P

Ill make this as a mod. Need to learn more about creating a mod :P

Burke ♞ Knight

#12
Why do you think I made my avatar mod?
Never made one of those before....LOL

EDIT:

Also, for those with Simple Portal, maybe add the way to change it in the user info block:
Sources/PortalBlocks.php

Find:<a href="', $scripturl, '?action=profile;u=', $member_info['id'], '">', $member_info['avatar']['image'], '</a><br /><br />';

if (!empty($member_info['group']))
echo '
', $member_info['group'], '<br />';
else
echo '
', $member_info['post_group'], '<br />';



Replace:<a href="', $scripturl, '?action=profile;u=', $member_info['id'], '">', $member_info['avatar']['image'], '</a><br /><br />';

if (!empty($member_info['group']))
echo '
<li class="membergroup"><img src="http://YOURDOMAIN.com/ranks/', $member_info['id'], '.png"> </li><br />';
else
echo '
', $member_info['post_group'], '<br />';


Dhayzon


makedir

I think its a cool idea of displaying group icon

ivanushka

Quote from: makedir on August 14, 2013, 06:11:33 AM
I think its a cool idea of displaying group icon

It's an excellent idea. An idea worth a million LOL

hxxp:google.com [nonactive]

LavaShakes

wow! this is so cool! i will try this.

Advertisement: