XF 2 Tip Display only age in profile.

momokan

Active member
Registered
Joined
May 17, 2020
Messages
44
Points
28

Reputation:

The birthday and age will be displayed by unchecking the following checkboxes in the advanced settings of your account.
1679782046316.png

Profile view screen
1679782773169.png

Lines 14 through 30 of the member_about template display birthdays and ages.
HTML:
                    <xf:if contentcheck="true">
                        <dl class="pairs pairs--columns pairs--fixedSmall">
                            <dt>{{ phrase('birthday') }}</dt>
                            <dd>
                                <xf:contentcheck>
                                    <xf:if is="$user.Profile.birthday.timeStamp">
                                        {{ date($user.Profile.birthday.timeStamp, $user.Profile.birthday.format) }}
                                        <xf:if is="$user.Profile.birthday.age">
                                            {{ parens(phrase('age:') . ' ' . {$user.Profile.birthday.age}) }}
                                        </xf:if>
                                    </xf:if>
                                </xf:contentcheck>
                            </dd>
                        </dl>
                    </xf:if>

Can you give me some advice on customization?
 

thomsa

Moderator
Staff member
Moderator
S.V.I.P Member
Collaborate
Registered
Joined
Jun 22, 2019
Messages
1,067
Points
173

Reputation:

Last edited:

momokan

Active member
Registered
Joined
May 17, 2020
Messages
44
Points
28

Reputation:

thomsaIt would be easy to remove the original functionality, but we would like to keep the user option.
I'm wondering if we can use conditional branching instead of deleting line 23.

HTML:
<xf:if contentcheck="true">
    <div class="block-row block-row--separated">
    <xf:contentcheck>
        <xf:if contentcheck="true">
            <dl class="pairs pairs--columns pairs--fixedSmall">
                <dt>{{ phrase('birthday') }}</dt>
                <dd>
                    <xf:contentcheck>
                        <xf:if is="$user.Profile.birthday.timeStamp">
                                {{ date($user.Profile.birthday.timeStamp, $user.Profile.birthday.format) }}
                            <xf:if is="$user.Profile.birthday.age">
                                {{ parens(phrase('age:') . ' ' . {$user.Profile.birthday.age}) }}
                            </xf:if>
                        </xf:if>
                    </xf:contentcheck>
                </dd>
            </dl>
<xf:else />
            <dl class="pairs pairs--columns pairs--fixedSmall">
                <dt>{{ phrase('age') }}</dt>
                <dd>
                    
                </dd>
            </dl>
</xf:if>
 

momokan

Active member
Registered
Joined
May 17, 2020
Messages
44
Points
28

Reputation:

In Xenforo 2.1, it seems to be possible to directly call the age as follows, but this does not work in Xenforo 2.2.
Code:
$xf.visitor.Profile.getAge(true)
 
Top