Combining 2 "Custom Profile Fields" in to 1

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
Webmaster Chuck
Registered User
Posts: 39
Joined: Thu Feb 25, 2016 10:21 pm
Location: Glendale, AZ
Name: Charles Waters
Contact:

Combining 2 "Custom Profile Fields" in to 1

Post by Webmaster Chuck » Sun May 26, 2019 11:35 pm

Good afternoon, all...

If this is posted in the wrong spot, I apologize. I didn't really see another appropriate place for this.

So on here, in the profile area, there is a spot for "First Name" and "Last Name". And when you look up a users profile, it has them combined.

I take it that was usage of the Custom Profile Fields?

If so, how were the combined as one?

Thank you in advance.

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 2259
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by kinerity » Mon May 27, 2019 3:57 pm

Code: Select all

<!-- 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 -->
It's actually documented in viewtopic.html

Code: Select all

		<!-- IF postrow.S_PROFILE_FIELD1 -->
			<!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
			<dd><strong>{postrow.PROFILE_FIELD1_NAME}{L_COLON}</strong> {postrow.PROFILE_FIELD1_VALUE}</dd>
		<!-- ENDIF -->
Kailey Truscott - Community Team

User avatar
Webmaster Chuck
Registered User
Posts: 39
Joined: Thu Feb 25, 2016 10:21 pm
Location: Glendale, AZ
Name: Charles Waters
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by Webmaster Chuck » Tue May 28, 2019 4:46 pm

kinerity wrote:
Mon May 27, 2019 3:57 pm

Code: Select all

<!-- 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 -->
It's actually documented in viewtopic.html

Code: Select all

		<!-- IF postrow.S_PROFILE_FIELD1 -->
			<!-- Use a construct like this to include admin defined profile fields. Replace FIELD1 with the name of your field. -->
			<dd><strong>{postrow.PROFILE_FIELD1_NAME}{L_COLON}</strong> {postrow.PROFILE_FIELD1_VALUE}</dd>
		<!-- ENDIF -->
Thank you. It works perfectly (to a point) by adding that line to /styles/templates/viewtopic_body.html.

However, it not only shows the combined "Name:" like I wanted, but it also duplicates it below. If I turn the "Display on viewtopic" off in the field declarations itself, then whichever one (or both) that is turned off, won't display at all.
name.png
Two fields in to one
name.png (9.35 KiB) Viewed 293 times
What the heck am I doing wrong?

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 2259
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by kinerity » Tue May 28, 2019 9:28 pm

Wrap the custom profile fields loop in an if/endif statement?

Code: Select all

			<!-- IF 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 -->
Kailey Truscott - Community Team

User avatar
Webmaster Chuck
Registered User
Posts: 39
Joined: Thu Feb 25, 2016 10:21 pm
Location: Glendale, AZ
Name: Charles Waters
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by Webmaster Chuck » Tue May 28, 2019 10:27 pm

kinerity wrote:
Tue May 28, 2019 9:28 pm
Wrap the custom profile fields loop in an if/endif statement?

Code: Select all

			<!-- IF 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 -->
Okay, so I've got two things...

1) If I use the code you listed above, I get nothing displayed at all:
notcorrected.png
notcorrected.png (11.36 KiB) Viewed 249 times
2) If I correct it as follows:

Code: Select all

			<!-- IF not postrow.custom_fields.S_PROFILE_FIRST_NAME and not postrow.custom_fields.S_PROFILE_LAST_NAME -->
				<dd><strong>Name:</strong> {postrow.PROFILE_FIRST_NAME_VALUE} {postrow.PROFILE_LAST_NAME_VALUE}</dd>
			<!-- 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 -->
Then it displays twice:
corrected.png
corrected.png (12.32 KiB) Viewed 249 times
I promise I *REALLY* am not this stupid. I just can't figure this one out.

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 2259
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by kinerity » Wed May 29, 2019 12:51 am

OK, let me play with it for a bit and I'll get back to you.

Edit: OK, I promise this works.
Replace

Code: Select all

		<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
		<!-- BEGIN custom_fields -->
			<!-- 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 -->
		<!-- END custom_fields -->
		<!-- EVENT viewtopic_body_postrow_custom_fields_after -->
With

Code: Select all

		<!-- 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_before -->
		<!-- BEGIN custom_fields -->
			<!-- IF 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 -->
		<!-- EVENT viewtopic_body_postrow_custom_fields_after -->
Kailey Truscott - Community Team

User avatar
Webmaster Chuck
Registered User
Posts: 39
Joined: Thu Feb 25, 2016 10:21 pm
Location: Glendale, AZ
Name: Charles Waters
Contact:

Re: Combining 2 "Custom Profile Fields" in to 1

Post by Webmaster Chuck » Thu May 30, 2019 5:21 pm

kinerity wrote:
Wed May 29, 2019 12:51 am

Edit: OK, I promise this works.

Replace

Code: Select all

		<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
		<!-- BEGIN custom_fields -->
			<!-- 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 -->
		<!-- END custom_fields -->
		<!-- EVENT viewtopic_body_postrow_custom_fields_after -->
With

Code: Select all

		<!-- 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_before -->
		<!-- BEGIN custom_fields -->
			<!-- IF 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 -->
		<!-- EVENT viewtopic_body_postrow_custom_fields_after -->
Bingo! As promised, works like a champ! That would actually be awesome to include in future releases. If it's used, awesome, and no one has to try and figure it out again. If it's not used, it doesn't hurt anything or anyone.

Thanks again for the support! Feel free to Close this topic.

Post Reply

Return to “[3.2.x] Support Forum”