[Snippet] Different rank image in each style

Little Mods and Snips 1

[Snippet] Different rank image in each style

Postby Sekuro » 27 Jun 2012, 11:18

Different rank image in each style

With this Snippet you can have a different rank image in each style

phpbb3-Version: 3.0.10

Requested by: Th3 Cr0w
Request Topic: http://www.phpbb.com/community/viewtopi ... &t=2153459

Demo:
memberlist: prosilver - subsilver2
viewtopic: prosilver - subsilver2

Instruction

open

includes/functions_display.php

find

Code: Select all
/**
* Get user rank title and image


before add

Code: Select all
/**
* Get user rank img for different styles
*/
// Different rank image in each style / 4seven / 2012
function get_style_rank_img($style_id, $rank_img, $rank_title)
{

global $user, $phpbb_root_path, $config;

if (request_var('style', 0) !== 0)
{
$style_id = request_var('style', 0);
}

return $rank_img = '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . substr($rank_img, 0, -4) . '_style_' . $style_id . substr($rank_img, -4) . '" alt="' . $rank_title . '" title="' . $rank_title . '" />';

}


/**
* Get user rank img src for different styles
*/
// Different rank image in each style / 4seven / 2012
function get_style_rank_img_src($style_id, $rank_img, $rank_title)
{

global $user, $phpbb_root_path, $config;

if (request_var('style', 0) !== 0)
{
$style_id = request_var('style', 0);
}

return $rank_img_src = $phpbb_root_path . $config['ranks_path'] . '/' . substr($rank_img, 0, -4) . '_style_' . $style_id . substr($rank_img, -4);



find

Code: Select all
        $rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';        
        $rank_img_src 
= (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';


replace with

Code: Select all
        //$rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';        
        //$rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';

                    // Different rank image in each style / 4seven / 2012
                    $rank_img     = (!empty($ranks['special'][$user_rank]['rank_image'])) ? get_style_rank_img($user->data['user_style'], $ranks['special'][$user_rank]['rank_image'], $ranks['special'][$user_rank]['rank_title']) : '';
                    $rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? get_style_rank_img_src($user->data['user_style'], $ranks['special'][$user_rank]['rank_image'], $ranks['special'][$user_rank]['rank_title']) : '';
                    // Different rank image in each style / 4seven / 2012           


find

Code: Select all
                    $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
                    $rank_img_src = (!empty($rank['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] : '';


replace with

Code: Select all
                    // $rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
                    // $rank_img_src = (!empty($rank['rank_image'])) ? $phpbb_root_path . $config['ranks_path'] . '/' . $rank['rank_image'] : '';

                    // Different images for an specified image rank in different styles / 4seven / 2012
                    $rank_img     = (!empty($rank['rank_image'])) ? get_style_rank_img($user->data['user_style'], $rank['rank_image'], $rank['rank_title']) : '';
                    $rank_img_src = (!empty($rank['rank_image'])) ? get_style_rank_img_src($user->data['user_style'], $rank['rank_image'], $rank['rank_title']) : '';
                    // Different images for an specified image rank in different styles / 4seven / 2012           


Usage:

You must upload a "Fake Image" for each rank, you want to add to various styles. eg rank_1.png to images/ranks.

After that find out which active styles you have and which style-id's they have, eg. (1,2,3), means eg (prosilver, subsilver, subblue).

Now upload to images/ranks three style dependent rank images, which must have the following syntax:

Remember you fake image is named rank_1.png ;)

Now upload three images with the following syntax: rank_1_style_STYLE_ID.png

So the names for the uploaded style depending images must be:

    rank_1_style_1.png
    rank_1_style_2.png
    rank_1_style_3.png

Thats all

So just two Steps:

    Upload fake rank image
    Upload three style dependent rank images

Ready
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900


Return to Snip Cl@ss I

Who is online

Users browsing this forum: No registered users and 1 guest

cron