Name special effects

Started by Decompiler, March 21, 2013, 03:20:37 PM

Previous topic - Next topic

Decompiler

Is it possible to add a "sparkle" effect to certain usernames? Or membergroups?

E.g:

In other forum softwares you can place a sparkle gif background behind the username, which gives you a "sparkle" effect. Does it work that way too in SMF? And if so then how and where do I add the gif?


Decompiler

You know I did search before I posted this. There's really nothing in there that answers my question. A lot of people are looking for what I'm looking for, but non of them seem to have found a way to do it.

Can you post a mini tutorial showing how you did it?

Shambles

Well, I edited Display.template.php to check for a specific username (in this case, the guy is called "Dazzler") and added the following in the section headed "// Show online and offline buttons?"


if ($message['member']['id'] == 60)
{
echo '<span style="color: #ff0000; background: url(http://www.mydomain.com/forum/bgeffects/sparkle.gif) no-repeat;"',
$message['member']['link'],
'</span> ';
}

vbgamer45

Ah that's a neat trick! I like that. Hmm If I had a list of images to use would make a cool mod.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Decompiler

Quote from: Shambles on March 21, 2013, 04:00:48 PM
Well, I edited Display.template.php to check for a specific username (in this case, the guy is called "Dazzler") and added the following in the section headed "// Show online and offline buttons?"


if ($message['member']['id'] == 60)
{
echo '<span style="color: #ff0000; background: url(http://www.mydomain.com/forum/bgeffects/sparkle.gif) no-repeat;"',
$message['member']['link'],
'</span> ';
}


I tried that, it worked, but it created a new name area under "Karma", it didn't replace the actual name at the top.

Quote from: vbgamer45 on March 21, 2013, 04:08:05 PM
Ah that's a neat trick! I like that. Hmm If I had a list of images to use would make a cool mod.


1-
2-
3-
4-
5-
6-

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Shambles

Quote from: Decompiler on March 21, 2013, 08:03:49 PM
I tried that, it worked, but it created a new name area under "Karma", it didn't replace the actual name at the top.
You have to place the span around the displayed name. I just snipped you an example of my code.

Decompiler

Quote from: vbgamer45 on March 21, 2013, 09:33:42 PM
Any more gifs?

The point of the mod shouldn't be to have a bunch of predefined gifs. The forum administrator should be able to upload and set any background to a username. Some people for example would want to have a minecraft themed background behind their username, and so on. Not everyone is going to use it for the "sparkly" effect.

Quote from: Shambles on March 22, 2013, 05:01:19 AM
You have to place the span around the displayed name. I just snipped you an example of my code.

Displayed name? Where do I find that? Can you post a step by step guide on how to do it?

Shambles

Well, since my earlier post, I amended my system to use this effect in a simpler and more manageable way.

I now use a new custom profile field for each member, which is used to hold the name of a background gif; I've set the profile field as "admin only" so that only admin can see or amend the field.

A very small change to Display.php now checks if a member has anything in the new profile field and wraps the members name with a 'span' to add that background image, if required.

A selection of background images is kept in a separate directory on my forum.


Quote
Displayed name? Where do I find that? Can you post a step by step guide on how to do it?
I'll assume you know nothing about anything I just wrote, so here goes:

Admin > Configuration > Core Features.
Ensure Advanced Profile Fields is enabled; if not, enable it and hit the "save" button.

Admin > Configuration > Features and Options > Profile Fields.
In the "Custom Profile Fields" section click "New Field" to add a new profile field.

- Give the field a name (I chose "Background GIF")
- Choose the profile section (I chose Look & Layout)
- Set Show On Registration to No
- Untick 'Show On Topic View'
- Set Placement to "Standard with Title"
- Set Field Type to 'text'
- Set Privacy to 'This field is only visible to Admins'
- Tick the Active box.

Hit SAVE.

Edit Sources/Display.php as follows:

Code (Find) Select

function prepareDisplayContext($reset = false)
{


Code (Add After) Select

global $boardurl;



Code (Find) Select

$memberContext[$message['id_member']]['ip'] = $message['poster_ip'];


Code (Add Before) Select

if (!empty($memberContext[$message['id_member']]['options']['cust_backgr']))
{
$saveme = $memberContext[$message['id_member']]['link'];

$memberContext[$message['id_member']]['link'] =
'<span style="color: #ff0000; background: url(' .
$boardurl . '/bgeffects/' .
$memberContext[$message['id_member']]['options']['cust_backgr'] .
') no-repeat;">' . $saveme .
'</span>';

$memberContext[$message['id_member']]['options']['cust_backgr'] = '';
}



Notes:
- the name you chose for the profile field will affect the index name used in the code. I chose "Background GIF" which gives rise to ['cust_backgr'] in the code. Change to suit.
- I put all my GIFs into a directory called "/bgeffects", which you will see in the above code. Change to suit.


Any questions, just ask.

Decompiler

Thank you, that works. I still have one problem though. The gifs aren't centered, they're way beneath the username, so only the top of the gifs can be seen.

For example when I tried this gif only the top 2 bars were visible. Is there a way to center the gif on the username?

Shambles

Quote from: Decompiler on March 23, 2013, 06:48:19 AM
Is there a way to center the gif on the username?

Sort of... Try this:

Code (Find) Select
$memberContext[$message['id_member']]['link'] =
'<span style="color: #ff0000; background: url(' .
$boardurl . '/bgeffects/' .
$memberContext[$message['id_member']]['options']['cust_backgr'] .
') no-repeat;">' . $saveme .
'</span>';



Code (Replace) Select
$memberContext[$message['id_member']]['link'] =
'<span style="color: #ff0000; background: url(' .
$boardurl . '/bgeffects/' .
$memberContext[$message['id_member']]['options']['cust_backgr'] .
') no-repeat scroll 0% 100% transparent;">' . $saveme .
'</span>';

Decompiler

That worked [though I changed the position values to 50% 60%].

Thanks for taking the time to help me! :laugh:

qubbah

not show in username block for tinyportal... how can i make it?

Shambles

Quote from: qubbah
not show in username block for tinyportal... how can i make it?

Almost 7 years membership, you should know that you won't get much joy asking a new question in an already-solved (and someone else's) thread.

XeAspire

Quote from: Decompiler on March 21, 2013, 08:03:49 PM
Quote from: Shambles on March 21, 2013, 04:00:48 PM
Well, I edited Display.template.php to check for a specific username (in this case, the guy is called "Dazzler") and added the following in the section headed "// Show online and offline buttons?"


if ($message['member']['id'] == 60)
{
echo '<span style="color: #ff0000; background: url(http://www.mydomain.com/forum/bgeffects/sparkle.gif) no-repeat;"',
$message['member']['link'],
'</span> ';
}


I tried that, it worked, but it created a new name area under "Karma", it didn't replace the actual name at the top.

Quote from: vbgamer45 on March 21, 2013, 04:08:05 PM
Ah that's a neat trick! I like that. Hmm If I had a list of images to use would make a cool mod.


1-
2-
3-
4-
5-
6-
I think that a name which changes colour will be cool. Like on IPB

Gargoyle

Very cool!!!   Thanks for the write up!

legendofkorra

Quote from: Shambles on March 22, 2013, 05:22:42 PM

Any questions, just ask.

thank you for descriping it step by step
my question right now is; what to put into the profile field box, within the users account,  after all doing that?
just the url of the actuall background gif you want to use for that certain username?

Shambles

Quote
my question right now is; what to put into the profile field box ...

just the url of the actuall background gif you want to use for that certain username?

Yep.

Owen2222

Quote from: Shambles on March 22, 2013, 05:01:19 AM
Quote from: Decompiler on March 21, 2013, 08:03:49 PM
I tried that, it worked, but it created a new name area under "Karma", it didn't replace the actual name at the top.
You have to place the span around the displayed name. I just snipped you an example of my code.

Hello Sir can you help me with this I tried it but when I enter URL in profile field it doesn't work I am really noob with these kinds of stuff If I send u my display file can u fix the bugs for me

Advertisement: