Help with custom profile field as picture :(

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Get Involved
Post Reply
Justsomeanimelover
Registered User
Posts: 11
Joined: Tue Feb 14, 2017 2:53 am

Help with custom profile field as picture :(

Post by Justsomeanimelover » Mon Feb 20, 2017 7:10 pm

Hello,

I'm having a little trouble getting a custom profile field show up as an image. I got it to work, however it shows up twice (the orange panes with the white fox).

Image

I've created a custom profile field called "vipbadges" and made it a dropdown. Each value here is the name of a picture, along with png. The idea is that members can choose from an existing number of badges uploaded to the server. e.g;

bleach1.png
bleach2.png
bleach3.png

These are stored in the folder images/vip_badges. The value from the dropdown and the code I added together form the path to the picture to be show.

I changed the view_topicbody.html to show the input as a picture accordingly:

Code: Select all

<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->
Now strangely it shows the picture twice, and the name of the picture "bleach1.png" in the middle. The idea was of course that the picture was only shown once and substituted the "bleach1.png" entirely, the latter not being shown at all anymore.

This is my current custom_fields code:

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
<!-- ENDIF -->	
				
<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->	
				
<!-- END custom_fields -->
You'll find that I intentionally removed the left column to get rid of "User Title:" and "VIP Badge:" cluttering the area.

Any help? :c :C :C

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Mon Feb 20, 2017 7:15 pm

You want to move your new code outside of the custom_fields loop. Otherwise it is executing it for each of the custom fields you have enabled.

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Help with custom profile field as picture :(

Post by javiexin » Mon Feb 20, 2017 7:25 pm

Use this: viewtopic.php?f=456&t=2327001

It even has a clan/badge example.
-javiexin

Justsomeanimelover
Registered User
Posts: 11
Joined: Tue Feb 14, 2017 2:53 am

Re: Help with custom profile field as picture :(

Post by Justsomeanimelover » Mon Feb 20, 2017 7:26 pm

javiexin wrote:
Mon Feb 20, 2017 7:25 pm
Use this: viewtopic.php?f=456&t=2327001

It even has a clan/badge example.
-javiexin
I've been following that, but it says it is in BETA and explicitly tells you not to install on a live board. :/

Justsomeanimelover
Registered User
Posts: 11
Joined: Tue Feb 14, 2017 2:53 am

Re: Help with custom profile field as picture :(

Post by Justsomeanimelover » Mon Feb 20, 2017 7:30 pm

Brf wrote:
Mon Feb 20, 2017 7:15 pm
You want to move your new code outside of the custom_fields loop. Otherwise it is executing it for each of the custom fields you have enabled.
Well that's some progress, thank you. It now only shows the picture once. But the name of the picture (e.g. bleach1.png) is still there.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Mon Feb 20, 2017 7:59 pm

The name is being displayed by the loop code above.

You can change that IF to check for your profile field something like this:

Code: Select all

<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME neq "vipbadges" -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
<!-- ENDIF -->
<!-- ENDIF -->	

Justsomeanimelover
Registered User
Posts: 11
Joined: Tue Feb 14, 2017 2:53 am

Re: Help with custom profile field as picture :(

Post by Justsomeanimelover » Mon Feb 20, 2017 8:41 pm

Brf wrote:
Mon Feb 20, 2017 7:59 pm
The name is being displayed by the loop code above.

You can change that IF to check for your profile field something like this:

Code: Select all

<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT -->
<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME neq "vipbadges" -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
<!-- ENDIF -->
<!-- ENDIF -->	
I take it this also goes outside the custom fields section?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Mon Feb 20, 2017 8:56 pm

No. That is replacing the existing code that is inside the loop. It is putting in another IF to prevent your field from being displayed there.

User avatar
Neculai Anisor
Registered User
Posts: 172
Joined: Tue Jan 08, 2013 9:36 pm
Location: Renfrew, Renfrewshire, Scotland
Name: Neculai Anișor
Contact:

Re: Help with custom profile field as picture :(

Post by Neculai Anisor » Mon Feb 20, 2017 9:15 pm

Justsomeanimelover wrote:
Mon Feb 20, 2017 7:10 pm

Code: Select all

<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->
Try like this xD

Code: Select all

<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}.png" height="135" width="135">
<!-- ENDIF -->
Edit:
Oh. Wrong answer. Do it like this :

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and not postrow.S_PROFILE_VIPBADGE -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
				
<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->	
<!-- ENDIF -->					
<!-- END custom_fields -->
Image | Romanian Support Team | Animo @ phpBB.ro - Administrator

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Mon Feb 20, 2017 9:49 pm

Neculai Anisor wrote:
Mon Feb 20, 2017 9:15 pm
. Do it like this :

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and not postrow.S_PROFILE_VIPBADGE -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
				
<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->	
<!-- ENDIF -->					
<!-- END custom_fields -->
Nope. Leaving it like that inside the loop still executes the code each time the loop goes through.
Also, putting

Code: Select all

<!-- IF postrow.S_PROFILE_VIPBADGE -->
inside

Code: Select all

 not postrow.S_PROFILE_VIPBADGE -->
results in code that can never execute.
The proper way, inside the loop, is to check which field is being accessed with

Code: Select all

<!-- IF postrow.custom_fields.PROFILE_FIELD_NAME 
or some other indexed attibute, to prevent the field from being shown by the loop, or to execute the image html only for the one field.

User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier
Contact:

Re: Help with custom profile field as picture :(

Post by javiexin » Mon Feb 20, 2017 9:55 pm

And you will loose all of these changes whenever you do an upgrade...

User avatar
Neculai Anisor
Registered User
Posts: 172
Joined: Tue Jan 08, 2013 9:36 pm
Location: Renfrew, Renfrewshire, Scotland
Name: Neculai Anișor
Contact:

Re: Help with custom profile field as picture :(

Post by Neculai Anisor » Tue Feb 21, 2017 12:11 am

Brf wrote:
Mon Feb 20, 2017 9:49 pm
Nope. Leaving it like that inside the loop still executes the code each time the loop goes through.
What about

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and not postrow.S_PROFILE_VIPBADGE -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
<!-- ENDIF -->
<!-- END custom_fields -->
					
<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->	
Image | Romanian Support Team | Animo @ phpBB.ro - Administrator

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Tue Feb 21, 2017 1:13 pm

Neculai Anisor wrote:
Tue Feb 21, 2017 12:11 am
What about

Code: Select all

<!-- BEGIN custom_fields -->
<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and not postrow.S_PROFILE_VIPBADGE -->
	<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}">			{postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>			
<!-- ENDIF -->
<!-- END custom_fields -->
					
<!-- IF postrow.S_PROFILE_VIPBADGE -->
	<img src="images/vip_badges/{postrow.PROFILE_VIPBADGE_VALUE}" height="135" width="135">
<!-- ENDIF -->	
Nope. That prevents any of the other custom profile fields from showing if the user has vipbadge set.
As I was explaining before S_PROFILE_VIPBADGE should not be used inside the loop. It will either be true for all of the iterations or false for all of the iterations. The proper way is to check postrow.custom_fields.PROFILE_FIELD_NAME or some other such field that changes for each loop item.

User avatar
Neculai Anisor
Registered User
Posts: 172
Joined: Tue Jan 08, 2013 9:36 pm
Location: Renfrew, Renfrewshire, Scotland
Name: Neculai Anișor
Contact:

Re: Help with custom profile field as picture :(

Post by Neculai Anisor » Tue Feb 21, 2017 3:37 pm

Brf wrote:
Tue Feb 21, 2017 1:13 pm
Nope. That prevents any of the other custom profile fields from showing if the user has vipbadge set.
As I was explaining before S_PROFILE_VIPBADGE should not be used inside the loop. It will either be true for all of the iterations or false for all of the iterations. The proper way is to check postrow.custom_fields.PROFILE_FIELD_NAME or some other such field that changes for each loop item.

Code: Select all

<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
		<!-- BEGIN custom_fields -->
			<!-- IF postrow.custom_fields.S_PROFILE_SEE_USER_NOTES and postrow.custom_fields.PROFILE_FIELD_VALUE --><!-- IF postrow.custom_fields.PROFILE_FIELD_VALUE neq 'None Selected'--><dd><span style="color:red;font-weight:bold;">{postrow.custom_fields.PROFILE_FIELD_NAME}: {postrow.custom_fields.PROFILE_FIELD_VALUE}</span></dd><!-- ENDIF -->
			<!-- ELSEIF not postrow.custom_fields.S_PROFILE_FIRST_NAME and not postrow.custom_fields.S_PROFILE_LAST_NAME -->
			<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT -->
				<dd class="profile-custom-field profile-{postrow.custom_fields.PROFILE_FIELD_IDENT}"><strong>{postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON}</strong> {postrow.custom_fields.PROFILE_FIELD_VALUE}</dd>
			<!-- ENDIF -->
			<!-- ENDIF -->
		<!-- END custom_fields -->
		<!-- IF postrow.S_PROFILE_FIRST_NAME or postrow.S_PROFILE_LAST_NAME --><dd><strong>Name:</strong> {postrow.PROFILE_FIRST_NAME_VALUE} {postrow.PROFILE_LAST_NAME_VALUE}</dd><!-- ENDIF -->
		<!-- EVENT viewtopic_body_postrow_custom_fields_after -->
Is not the same thing on the phpbb.com template?
Image | Romanian Support Team | Animo @ phpBB.ro - Administrator

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Help with custom profile field as picture :(

Post by Brf » Tue Feb 21, 2017 3:44 pm

No. That is not the same.
That is using postrow.custom_fields.S_PROFILE_FIRST_NAME not postrow.S_PROFILE_FIRST_NAME

Apparently, this new version has a S_ flag within the loop, as well as outside. That makes it easier.

Post Reply

Return to “Extension Requests”