Page 1 of 1

Combining 2 "Custom Profile Fields" in to 1

Posted: Sun May 26, 2019 11:35 pm
by Webmaster Chuck
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.

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

Posted: Mon May 27, 2019 3:57 pm
by kinerity

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

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

Posted: Tue May 28, 2019 4:46 pm
by Webmaster Chuck
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 294 times
What the heck am I doing wrong?

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

Posted: Tue May 28, 2019 9:28 pm
by kinerity
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 -->

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

Posted: Tue May 28, 2019 10:27 pm
by Webmaster Chuck
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 250 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 250 times
I promise I *REALLY* am not this stupid. I just can't figure this one out.

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

Posted: Wed May 29, 2019 12:51 am
by kinerity
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 -->

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

Posted: Thu May 30, 2019 5:21 pm
by Webmaster Chuck
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.