IF Statements & Custom Profile Fields to hide profile info

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 7:55 pm

I've applied that under between POSTS and JOINED but nothing is showing (I've purged the cache and Ctrl + F5'd too).

(And changed TEST to the CPF identifier)

Edit:
</strong> xXx</dd>{% endif %}

If I've read this right will it show xXx? I'd like it to show their actual age, sorry if I wasn't clear on that.

Before, I've used:

Code: Select all

<!-- IF postrow.POSTER_AGE --><dd><strong>{L_AGE}{L_COLON}</strong> {postrow.POSTER_AGE}</dd><!-- ENDIF -->
which shows the age, it's just getting it to read the CPF choice.
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Registered User
Posts: 566
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: IF Statements & Custom Profile Fields to hide profile info

Post by GanstaZ » Sun Oct 07, 2018 8:17 pm

This will work, tested myself)

Code: Select all

{% if postrow.PROFILE_TEST_VALUE_RAW != 1 and postrow.POSTER_AGE %}<dd class="profile-age"><strong>{L_AGE}{L_COLON}</strong> {postrow.POSTER_AGE}</dd>{% endif %}
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 8:23 pm

:? It's showing the age OK, but turning the CPF to "No" doesn't hide it. This is exactly what I have in styles/prosilver/template/viewtopic_body.html lines 160 - 162:

Code: Select all

		<!-- IF postrow.POSTER_POSTS != '' --><dd class="profile-posts"><strong>{L_POSTS}{L_COLON}</strong> <!-- IF postrow.U_SEARCH !== '' --><a href="{postrow.U_SEARCH}"><!-- ENDIF -->{postrow.POSTER_POSTS}<!-- IF postrow.U_SEARCH !== '' --></a><!-- ENDIF --></dd><!-- ENDIF -->
	    {% if postrow.PROFILE_SHOWAGE_VALUE_RAW != 1 and postrow.POSTER_AGE %}<dd class="profile-age"><strong>{L_AGE}{L_COLON}</strong> {postrow.POSTER_AGE}</dd>{% endif %}
		<!-- IF postrow.POSTER_JOINED --><dd class="profile-joined"><strong>{L_JOINED}{L_COLON}</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF -->
		
(The CPF field identification is showage, which is what I've been using)
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
3Di
Registered User
Posts: 12983
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: IF Statements & Custom Profile Fields to hide profile info

Post by 3Di » Sun Oct 07, 2018 9:07 pm

Have you tried..
if postrow.PROFILE_SHOWAGE and postrow.POSTER_AGE ?
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 9:12 pm

3Di wrote:
Sun Oct 07, 2018 9:07 pm
Have you tried..
if postrow.PROFILE_SHOWAGE and postrow.POSTER_AGE ?
Hi, I've tried:

Code: Select all

	    {% if postrow.PROFILE_SHOWAGE and postrow.POSTER_AGE %}<dd class="profile-age"><strong>{L_AGE}{L_COLON}</strong> {postrow.POSTER_AGE}</dd>{% endif %}
	    
and

Code: Select all

<!-- IF postrow.PROFILE_SHOWAGE and postrow.POSTER_AGE --><dd class="profile-age"><strong>{L_AGE}{L_COLON}</strong> {postrow.POSTER_AGE}</dd><!-- ENDIF -->
but neither have worked.
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
3Di
Registered User
Posts: 12983
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: IF Statements & Custom Profile Fields to hide profile info

Post by 3Di » Sun Oct 07, 2018 9:25 pm

Two more attmpts

{% if postrow.PROFILE_SHOWAGE is not empty and postrow.POSTER_AGE %}
or
{% if postrow.PROFILE_SHOWAGE is not empty or postrow.PROFILE_SHOWAGE is not null and postrow.POSTER_AGE %}

you have to purge the cache after each template changes.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 9:28 pm

Hi, neither of these have worked either. The CPF is a Boolean Yes/No.
Thanks
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Registered User
Posts: 566
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: IF Statements & Custom Profile Fields to hide profile info

Post by GanstaZ » Sun Oct 07, 2018 9:29 pm

This now is working as you want, but you need to check this => Display on viewtopic screen

Code: Select all

		{% if postrow.POSTER_AGE and postrow.PROFILE_TEST_VALUE_RAW != 1 %}<dd class="profile-age"><strong>{{ lang('AGE') ~ lang('COLON') }}</strong> {{ postrow.POSTER_AGE }}</dd>{% endif %}
		<!-- IF postrow.POSTER_JOINED --><dd class="profile-joined"><strong>{L_JOINED}{L_COLON}</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF -->
		<!-- IF postrow.POSTER_WARNINGS --><dd class="profile-warnings"><strong>{L_WARNINGS}{L_COLON}</strong> {postrow.POSTER_WARNINGS}</dd><!-- ENDIF -->

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

		<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
		<!-- BEGIN custom_fields -->
			<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and postrow.custom_fields.PROFILE_FIELD_NAME != postrow.PROFILE_TEST_NAME -->
				<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 -->
"When answer lies in the question,.. question becomes redundant!"

User avatar
3Di
Registered User
Posts: 12983
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: IF Statements & Custom Profile Fields to hide profile info

Post by 3Di » Sun Oct 07, 2018 9:32 pm

{% if postrow.PROFILE_SHOWAGE is sameas(true) and postrow.POSTER_AGE %}
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 9:37 pm

GanstaZ wrote:
Sun Oct 07, 2018 9:29 pm
This now is working as you want, but you need to check this => Display on viewtopic screen

Code: Select all

		{% if postrow.POSTER_AGE and postrow.PROFILE_TEST_VALUE_RAW != 1 %}<dd class="profile-age"><strong>{{ lang('AGE') ~ lang('COLON') }}</strong> {{ postrow.POSTER_AGE }}</dd>{% endif %}
		<!-- IF postrow.POSTER_JOINED --><dd class="profile-joined"><strong>{L_JOINED}{L_COLON}</strong> {postrow.POSTER_JOINED}</dd><!-- ENDIF -->
		<!-- IF postrow.POSTER_WARNINGS --><dd class="profile-warnings"><strong>{L_WARNINGS}{L_COLON}</strong> {postrow.POSTER_WARNINGS}</dd><!-- ENDIF -->

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

		<!-- EVENT viewtopic_body_postrow_custom_fields_before -->
		<!-- BEGIN custom_fields -->
			<!-- IF not postrow.custom_fields.S_PROFILE_CONTACT and postrow.custom_fields.PROFILE_FIELD_NAME != postrow.PROFILE_TEST_NAME -->
				<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 -->
Hi, that's almost got it, except when "No" is selected it shows in the topic and not memberlist, and if "Yes" is selected it does not show in the topic but does on the memberlist.
The first option is Yes, the second is No.
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

User avatar
GanstaZ
Registered User
Posts: 566
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: IF Statements & Custom Profile Fields to hide profile info

Post by GanstaZ » Sun Oct 07, 2018 9:45 pm

Just change !=1 to == 1 and is all.
"When answer lies in the question,.. question becomes redundant!"

User avatar
Restless Rancor
Registered User
Posts: 182
Joined: Tue Sep 18, 2018 1:51 pm

Re: IF Statements & Custom Profile Fields to hide profile info

Post by Restless Rancor » Sun Oct 07, 2018 9:48 pm

Perfect!
Thank you both for your time and effort! I should probably get to bed now, I'm up in a few hours :oops:

Thanks again! :ugeek:
These aren't the droids you're looking for...
My Extensions and Snippets (Ref link)

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 5 guests