Custom profile field show up as image

Discussion forum for MOD Writers regarding MOD Development.
Locked
Goztow
Registered User
Posts: 376
Joined: Fri Aug 17, 2007 10:31 am
Location: Belgium
Contact:

Custom profile field show up as image

Post by Goztow »

I just developed this small custom modification for my phpbb3.0.4 forums and thought I'd share it with you. It's not a full mod and I won't really be able to support it as such, it's more of an aid for people who want to do the same thing.

If you're totally unfamiliar with phpbb modding, then do not touch this ;).

What I needed: our clan supports multiple games and we wanted members to be able to select the games they play in their profile and have a nice game logo show up in their profile and at viewtopic, memberslist, ...

1: I first made custom profile fields in the acp. Attention: you'll need to go to the "load settings" in the acp and configure the custom profile field to show on viewtopic and memberslist!

I personally choose for custom field "boolean", example: Renegade: yes/no

If you do this, something like
"Renegade: yes" will appear in your profile, viewtopic, ...

Now the modding part: go to includes/functions_profile_fields.

Around line 430, find:

Code: Select all

'PROFILE_FIELD_VALUE'    => $value, 
replace with

Code: Select all

'PROFILE_FIELD_VALUE'    => $prof_field_value, 
Around line 430, find:

Code: Select all

'PROFILE_FIELD_NAME'    => $ident_ary['data']['lang_name'], 
replace with

Code: Select all

'PROFILE_FIELD_NAME'    => $prof_field_name, 
Around line 430, find:

Code: Select all

$tpl_fields['blockrow'][] = array( 
Before, add

Code: Select all

                //Goz mod: custom profile field to show an image
                $prof_path = "images/custom_profile_fields/".$ident_ary['data']['lang_name'].".jpg";
                if (file_exists($prof_path)) {
                $prof_field_name = "<img src='images/custom_profile_fields/".$ident_ary['data']['lang_name'].".jpg' border='0'>";
                $prof_field_value = "".$ident_ary['data']['lang_name']." player";
                } else {
                $prof_field_name = $ident_ary['data']['lang_name'];
                $prof_field_value = $value;
                } 
Attention: the $path is the path where I put the image files. These image files have the exact same name (and are .jpg) as the name of the game. In this case: images/custom_profile_fields/Renegade.jpg . If this image does not exist, the usual custom profile field will continue appearing.

You may need to purge the cache.

There you go, it's as "simple" as this. I hope this can help some people.

Edit 08/01/09: updated this as there was a small mistake in it.
User avatar
girlintrouble
Registered User
Posts: 856
Joined: Fri Jan 25, 2008 8:35 pm
Location: UK

Re: Custom profile field show up as image

Post by girlintrouble »

This is useful - I may try it ;-)
User avatar
girlintrouble
Registered User
Posts: 856
Joined: Fri Jan 25, 2008 8:35 pm
Location: UK

Re: Custom profile field show up as image

Post by girlintrouble »

Actually Gostow, I have your musltip ranks mod install, this wont mess stuff up with that or conflict with it will it?
Goztow
Registered User
Posts: 376
Joined: Fri Aug 17, 2007 10:31 am
Location: Belgium
Contact:

Re: Custom profile field show up as image

Post by Goztow »

girlintrouble wrote:Actually Gostow, I have your musltip ranks mod install, this wont mess stuff up with that or conflict with it will it?
No, the ranks are not linked to the custom profile fields.
nasadows
Registered User
Posts: 119
Joined: Wed Mar 25, 2009 3:49 am

Re: Custom profile field show up as image

Post by nasadows »

is this applicable to put images for different VALUES of the CPF input, not the CPF name itself? For more than 2 choices we need to use Drop-down box, not Boolean, and I need each choice is an image

If this can be true, it is a great time-saver for no longer having to instal MODs like Genders MOD (edits too much!, it hardcodes the Profile field instead of making it a CPF and I think it is unnecessary). We simply need to add a new CPF and converts the values into images!

I wish there could be a way.
Thanks for any help.
Last edited by nasadows on Sat Oct 17, 2009 9:02 am, edited 1 time in total.
Goztow
Registered User
Posts: 376
Joined: Fri Aug 17, 2007 10:31 am
Location: Belgium
Contact:

Re: Custom profile field show up as image

Post by Goztow »

Looking at the code I created about a year back, I'd say it's 100 % possible.
nasadows
Registered User
Posts: 119
Joined: Wed Mar 25, 2009 3:49 am

Re: Custom profile field show up as image

Post by nasadows »

How, can you show me please? I've spent this whole morning thinking about it, but my modding skill is virtually null.

Can you help me please?
This is what I'm trying to do:

(1)Create a Dropdown box with 3 choices:
- Not specified
- Male
- Female
That (text) is what people see upon registration or in Profile settings
BUT:
in Memberlist and Viewtopic it displays the value as an image (it converts the value into images) (2)
for Male it is an image Male.gif in /images folder
for Female ...
for Not specified it is blank

Thank you very much
BushidoPT
Registered User
Posts: 6
Joined: Tue Feb 09, 2010 6:29 pm

Re: Custom profile field show up as image

Post by BushidoPT »

nasadows wrote:How, can you show me please? I've spent this whole morning thinking about it, but my modding skill is virtually null.

Can you help me please?
This is what I'm trying to do:

(1)Create a Dropdown box with 3 choices:
- Not specified
- Male
- Female
That (text) is what people see upon registration or in Profile settings
BUT:
in Memberlist and Viewtopic it displays the value as an image (it converts the value into images) (2)
for Male it is an image Male.gif in /images folder
for Female ...
for Not specified it is blank

Thank you very much
Any luck solving this problem?
Goztow
Registered User
Posts: 376
Joined: Fri Aug 17, 2007 10:31 am
Location: Belgium
Contact:

Re: Custom profile field show up as image

Post by Goztow »

I don't have the time to do it, sorry.
Locked

Return to “[3.0.x] MOD Writers Discussion”