1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Gender Conditionals

Discussion in 'XenForo Questions and Support' started by Amaury, Apr 9, 2015.

  1. Amaury

    Amaury Well-Known Member

    A while ago I created a phrase to use for status updates in the news feed (by default, there is no phrase and it just shows the username and the status itself). I just used their in the phrase, but is there a way I can make it display the appropriate gender pronoun as follows:
    • His (if the person has male as their gender)
    • Her (if the person has female as their gender)
    • Their (if the person has selected no gender)

  2. Liam W

    Liam W Well-Known Member

    Yes - the gender is stored in the gender field.

    So, this template content (news_feed_item_user_status) would work:

    <h3 class="description"><xen:username user="$user" class="primaryText" /> <xen:if is="{$user.gender} == 'male'">{xen:phrase updated_his_status}<xen:elseif is="{$user.gender} == 'female'" />{xen:phrase updated_her_status}<xen:else />{updated_their_status}</xen:if> <em>{xen:helper bodyText, $status.new}</em></h3>

    Edit: Drat, one problem :) Fixed now though, the code above is tested.
    Amaury likes this.
  3. Amaury

    Amaury Well-Known Member

    I'll give it a try when I'm back on my desktop. Thanks!
  4. Amaury

    Amaury Well-Known Member

    @Liam W, gave it a try, changing the phrase names to match accordingly, to no avail.
  5. Amaury

    Amaury Well-Known Member

  6. Jashugan

    Jashugan Member

    To be honest I don't know why this isn't already standard in Xenforo. I mean it's such a simple thing for the devs to include that would make XF better for everyone who uses it.
  7. Optic

    Optic Well-Known Member

    Did you create new phrases for this or hard-code them?
  8. Amaury

    Amaury Well-Known Member

    New phrase.
  9. Amaury

    Amaury Well-Known Member

    @Liam W, @Optic, still looking for some help when you have the time. :)
  10. mike406

    mike406 Member

    Using news_feed_item_user_status doesn't appear to work where we want to make this change, we found that news_feed_item_profile_post_insert is the necessary template. However $user.gender doesn't seem to work in this template, so we're stuck trying to figure out how we can distinguish gender here.
  11. Amaury

    Amaury Well-Known Member

  12. Brogan

    Brogan XenForo Moderator Staff Member

    Adding this to the template will show what is available for the user record:
    {xen:helper dump, $user}
    In this case just user_id and username are available in the news_feed_item_profile_post_insert template.

    Custom development would be required to make the gender available in the record.
    Amaury likes this.
  13. Amaury

    Amaury Well-Known Member

    @Brogan, thank you so much!

    I've let Mike know about your response.

    Really appreciate it!

Share This Page