Area51 @ 4seven.de

Mod Base and Testarea
It is currently 23 Feb 2025, 15:43

All times are UTC + 1 hour




Post new topic TOPIC_LOCKED  [ 1 post ] 
Author Message
PostPosted: 27 Jun 2012, 11:18 
Offline
Tiptop
Tiptop
User avatar

Joined: 11 Feb 2008, 11:49
Posts: 241
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:
/**
* Get user rank title and image


before add

Code:
/**
* 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:
        $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:
        //$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:
                    $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:
                    // $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:

Quote:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic TOPIC_LOCKED  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
[ Time : 0.011s | 21 Queries | GZIP : Off ]