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

Custom Gender Issues

Discussion in 'Styling and Customization Questions' started by MaxwellM, Feb 20, 2012.

  1. MaxwellM

    MaxwellM Member

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Those errors indicate a bad file edit.

    A custom field would be easier:

    Admin CP -> Users -> Custom User Fields
     
  3. MaxwellM

    MaxwellM Member

    I would much rather have more built-in gender options. The errors I am getting are not on the lines I am changing. They're usually closing tags, which (again), appear to be formatted correctly. Maybe a quick editing guide may be more helpful?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you post the code changes? I can look for errors.
     
  5. MaxwellM

    MaxwellM Member

    In template search:

    account_personal_details
    (no errors produced)
    Code:
    <li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$visitor.gender} == 'male'"} /> {xen:phrase male}</label></li>
    <li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$visitor.gender} == 'female'"}  /> {xen:phrase female}</label></li>
    <li><label for="ctrl_gender_bigender"><input type="radio" name="gender" value="bigender" id="ctrl_gender_bigender" {xen:checked "{$visitor.gender} == 'bigender'"}  /> {xen:phrase bigender}</label></li>
    
    register_form (no errors produced)
    Code:
    <li><label for="ctrl_gender_male"><input type="radio" name="gender" value="male" id="ctrl_gender_male" {xen:checked "{$fields.gender} == 'male'"} /> {xen:phrase male}</label></li>
    <li><label for="ctrl_gender_female"><input type="radio" name="gender" value="female" id="ctrl_gender_female" {xen:checked "{$fields.gender} == 'female'"} /> {xen:phrase female}</label></li>
    <li><label for="ctrl_gender_bigender"><input type="radio" name="gender" value="bigender" id="ctrl_gender_bigender" {xen:checked "{$fields.gender} == 'bigender'"} /> {xen:phrase bigender}</label></li>
    <li><label for="ctrl_gender_"><input type="radio" name="gender" value="" id="ctrl_gender_" {xen:checked "!{$fields.gender}"} /> ({xen:phrase unspecified})</label></li>
    
    member_view (both instances in the script were changed to match)
    Code:
    <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:if is="{$user.gender} == 'bigender'">{xen:phrase bigender}<xen:else />{xen:phrase female}</xen:if></dd>
    
    Error: The following templates contained errors and were not saved: member_view: 1) Line 151: Template syntax error.

    message_user_info
    Code:
    <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:if is="{$user.gender} == 'bigender'">{xen:phrase bigender}<xen:else />{xen:phrase female}</xen:if></dd>
    
    Error: The following templates contained errors and were not saved: message_user_info: 1) Line 84: Template syntax error.

    The error lines are just the closing tag (/dl). Correct me if I'm wrong, but doesn't the new gender reside within the same containing tag, and thus not needing a new one?

    What else needs to be edited? Within the PHP scripts mentioned in the other thread, what needs to be changed?

    I appreciate your assistance :)
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Change this part:

    Code:
    <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:if is="{$user.gender} == 'bigender'">{xen:phrase bigender}<xen:else />{xen:phrase female}</xen:if></dd>
    
    To this:

    Code:
    <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:elseif is="{$user.gender} == 'bigender'" />{xen:phrase bigender}<xen:else />{xen:phrase female}</xen:if></dd>
    
    That should do it. It's similar for the other template.
     
  7. MaxwellM

    MaxwellM Member

    ahh, yes! The self-closing tag. Almost forgot about that. Many thanks to you, Jake! Is there anything else I need to do in order to make this functional? You mentioned some database changes in the other thread...

    Also, I'm still rather new to XF. Where should I go to define default avatars for each gender?
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  9. MaxwellM

    MaxwellM Member

    Weird, when I search in my database, I don't see any fields containing the word 'gender.' What table/column is it named or contained within by default?

    Also, I'm still looking to change the default avatars for each gender. Where would I go to do that? These are pretty much the last two major things that I need.
     
  10. Morgain

    Morgain Well-Known Member

    Maxwell I changed the default gender avatars like this:

    Created 3 avatars for each gender.
    Sizes:
    avatar_female_l.png 192 X 154
    avatar_female_m.png 96 X 76
    avatar_female_s.png 48 X 39

    So 3 male ones the same and the neutral one.

    In the XF directory
    \styles\default\xenforo\avatars

    Rename all those 9 avatars - eg add "ORIG" on the end of the name.
    By doing this you have the original files to compare or use as a basis for other designs later. I always do this when hacking to be safe.

    Upload the new avatars into this folder.
    By renaming the old ones with ORIG on the END of the name, the new ones sit with the old ones so you can double check you have the filenames correct.

    That's it.

    But I don't know what you do about giving your custom gender statuses a default avatar. You could rename Unspecified for one of them? I'm sure Jake or someone clever can help you take this further.
     
  11. MaxwellM

    MaxwellM Member

    Hi Morgain,

    I very much appreciate your input, but unfortunately this does not help me in regards to defining the default avatar for custom genders (as you said). But I very much appreciate you taking the time to advise others, so you get points for that :)

    I guess we'll just to wait to hear Jake's suggestions on both of these matters (the database and the avatars).
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The table is xf_user. The field is gender.

    The avatars are in styles/default/xenforo/avatars.

    The use of those avatars is defined in the PHP code:

    library/XenForo/Template/Helper/Core.php
     
  13. MaxwellM

    MaxwellM Member

    Jake, are you sure any modifications are necessary on the PHP scripts and in the database? I'm not seeing anything that would inhibit the new custom genders from being functional, at least from what I'm seeing.
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I have never tried implementing all of the necessary modifications because it's a very dirty thing to do and I don't recommend it. But my post in this thread lists all of the areas I found that need to be modified:

    http://xenforo.com/community/threads/can-i-add-a-gender-option-i-e-couple.7276/

    This might not be a complete list.

    I still recommend using a custom field:

    Admin CP -> Users -> Custom User Fields
     
  15. MaxwellM

    MaxwellM Member

    Right, but what lines actually need to be modified in the PHP files? Everything that I'm reading appears to be fine. If you can give me an example of the changes that need to be made, I'd be eternally grateful.
     
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I don't have detailed instructions. My post was more meant as a pointer for a programmer who wants to make the attempt.
     
  17. MaxwellM

    MaxwellM Member

    Maybe a better question would be: what evidence leads you to the conclusion that those files need to be edited? As I said earlier, it looks like things appear to be in line. My PHP skills aren't perfect, so if there are any programmers reading this that want to chime in, I'd be quite grateful.
     
  18. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page