Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Vanilla 2.2.1 is now available.
Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.

Option to display gender on user profile page

edited September 2010 in Vanilla 2.0 Help
On signup vanilla asks a user their gender but this isn't displayed on the user profile pages by default. Is there an option somewhere on the dashboard to display it?
Tagged:

Comments

  • edited September 2010
    That's a good answer!
  • Hmmm.. can a simple php line be inserted to the profile page?
  • RaizeRaize vancouver ✭✭
    I bet it gets stored in the database, so a php command that draws from that would need to be added from the profile page... eazy breezy if you know how :p
  • how to show in user profile gender? or bottom of user avatar
  • how to show in user profile gender? or bottom of user avatar

    Either would be fine.
  • LincLinc Vanilla's Bard Detroit Vanilla Staff
    FYI, it's actually used by the activity statements so it knows to use he/she in them.
  • It can be done by adding

    <?php echo T('Gender'); ?>
    <?php echo ($this->User->Gender); ?>

    to userinfo.php

    gender is stored in the database as a lower case "m" or "f" so I am guessing more code would need to be added to make it display "male" or "female". I have no idea what that would look like.
  • LincLinc Vanilla's Bard Detroit Vanilla Staff
    To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>
  • To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>

    Thanks Lincoln! works like a charm.
  • Lincoln said:
    To accomplish that the second line could become:

    <?php echo ($this->User->Gender == 'm') ? 'Male' : 'Female'; ?>

    Will something other than a ternary operator work?
    I want to be able to have "entities" that represent groups.
    I have created another "gender" which is g for group - some of the rendered sentences look VERY odd.
    Can't see that a switch-case would work.

  • peregrineperegrine MVP
    edited May 2012

    Of course you would have to find all the tests in all the programs and modify the gender conditional everywhere.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited May 2012

    you can do anything you want for a conditional if then else, if than elseif, why wouldn't switch-case work??

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • edited May 2012

    I was thinking of switch-case not working in a one line statement as you have in /library/core/class.format.php.

    EG $Gender = T($Activity->ActivityGender == 'm' ? 'his' : 'her');.

    I have used:

    switch ($Activity->ActivityGender){
                        case "m":
                            $Gender = "his";
                            break;
                        case "f":
                            $Gender = "her";
                            break;
                        default:
                            $Gender = "their";
                    }

    And...

    switch ($Activity->ActivityGender){
                    case "m":
                        $Gender2 = "he";
                        break;
                    case "f":
                        $Gender2 = "she";
                        break;
                    default:
                        $Gender2 = "they";
                }

    Need to have a play around to see if it is performing as expected.

  • edited May 2012

    I want to place an associative array somewhere that can be used globally to convert m,f,t to Male,Female,Transvestite as required.

    I have done this in applications/dashboard/views/modules/userinfo.php....

    `
    $GenderArray = array('m'=>'Male', 'f'=>'Female', 't'=>'Transvestite');

    <dt class="Name"><?php echo T('Gender'); ?></dt><dd><?php while(list($key,$value) = each($GenderArray)) {if ($key == $this->User->Gender) {echo $value; }} ?></dd></dt>
    `

    ...but don't want to place it on every page where it might be required. That would be silly.
    (BTW will code this a bit better later on)

    Am still getting grips with the programming approach of this system so they may be a more logical mechanism than an associative array.

    If this array is best strategy then where best to place it?
    Root index.php?
    bootstrap.php
    a config file?

Sign In or Register to comment.