Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Jennifer RachaelAnn on April 19, 2017, 07:46:04 PM

Title: Genders
Post by: Jennifer RachaelAnn on April 19, 2017, 07:46:04 PM
The board I run is a transgender support forum. I want to know is there any way to add to or modify the gender section? I would like to give people several options, and have tinkered with the file, but nothing I try works.
Title: Re: Genders
Post by: Linkjay on April 19, 2017, 08:30:46 PM
Simply? No.

Genders, by default, are done by numbering on the forums. 0 = Other/None and then 1 and 2 are Male and Female. You would have to modify all the sections where a drop-down comes down to set genders and set the values above 2 and then go to all the sections where gender is displayed or edited and then work in the numbers.

If I were to go about this, I might work with titles under the names, groups, or have them put things in their signatures. You could add a custom profile field for this too. All in all, I think messing with the base genders for SMF is a bad idea and quite a challenge.
Title: Re: Genders
Post by: Kindred on April 19, 2017, 09:49:07 PM
there was a mod for it...
Title: Re: Genders
Post by: Sir Osis of Liver on April 19, 2017, 10:51:36 PM
There are two, one will not install in 2.0 (it was updated to RC2, but doesn't install with emulation), the other has been removed from mod list (pink).
Title: Re: Genders
Post by: shawnb61 on April 19, 2017, 11:26:31 PM
Hmmm...   Sure seems like a pretty basic need.  An odd limitation; I was thinking about that the other day.

Since you're in the Scripting section, looks like you're willing to give it a try.  First suggestion is to look very closely at those old mods for ideas. 

What type of errors are you getting?
Title: Re: Genders
Post by: shawnb61 on April 19, 2017, 11:33:08 PM
Look under Admin | Features & Options | Profile Fields.

I'd de-activate the default Gender field, and try adding your own. 

Make sure you use a placement like "with icons" so it's up there visible where you want it.
Title: Re: Genders
Post by: Linkjay on April 19, 2017, 11:46:26 PM
I was just messing around with custom fields the other day too. If you do decide to do this, try what Shawn said and disable default genders then use the custom field. Custom field values are stored in the smf_themes table. I actually did not know that myself and I finally found it and it allowed me to use that value for a little project I was doing.
Title: Re: Genders
Post by: Sir Osis of Liver on April 19, 2017, 11:52:48 PM
If custom fields are used, gender will not be displayed in poster info panel in display template.  Would require some custom coding to do that.
Title: Re: Genders
Post by: shawnb61 on April 20, 2017, 12:02:52 AM
Some screenshots provided of how you might make it work.

There's even an option to present it upon registration.
Title: Re: Genders
Post by: bestnow on April 20, 2017, 07:28:35 AM
FILE: Load.php  LINE: 1140  (Sources file)
find:

// Set things up to be used before hand.
$gendertxt = $profile['gender'] == 2 ? $txt['female'] : ($profile['gender'] == 1 ? $txt['male'] : '');


replace:

$gendertxt = $profile['gender'] == 2 ? $txt['female'] : $profile['gender'] == 1 ? $txt['male'] : ($profile['gender'] == 3 ? $txt['transgender'] : '') ;



FILE: Profile-Modify.php LINE: 305 (Sources file)

find:

'options' => 'return array(0 => \'\', 1 => $txt[\'male\'], 2 => $txt[\'female\']);',

replace:

'options' => 'return array(0 => \'\', 1 => $txt[\'male\'], 2 => $txt[\'female\'],  3 => $txt[\'transgender\']);',


FILE: index.english LINE 170 (Themes/default/languages file)
find:

$txt['female'] = 'Female';

add below

$txt['transgender'] = 'Transgender';










EXTRA INFO PICTURE GENDER if u want to add:



file: load.php LINE: 1180

Ex how the line looks like:

'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''









picture to see it finish:
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Foi67.tinypic.com%2F2lawi85.jpg&hash=6c7060904dd158d1b667ae0d4d6c248ceae431dd)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Foi67.tinypic.com%2F103zqlw.jpg&hash=c3ec8e7a13dec35c7212470f144d0a5920147e21)
Title: Re: Genders
Post by: Kindred on April 20, 2017, 08:36:37 AM
Actually, this mod
https://custom.simplemachines.org/mods/index.php?mod=2152

will almost install on 2.0.13, if you emulate "SMF 2.0 RC2" (no quotes)
the only failure is in Load.php for the image
The fix?
Install the mod and then make this specific change

Code (in Load.php, find) Select

'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''
   

Code (replace with ) Select

'image' => !empty($profile['gender']) ? '<img src="' . $settings['images_url'] . '/' . $genderimg . '" alt="' . $gendertxt . '" border="0" />' : ''



the nice thing about this mod is that it becomes fairly easy to change or add the choices -- just change the case statements as were added (see below) and then add additional images for each representation
Code (in Load.php) Select

switch($profile['gender']) {
            case 5:
                $gendertxt = $txt['intersexed'];
                $genderimg = 'intersexed.gif';
                break;
            case 4:
                $gendertxt = $txt['transf2m'];
                $genderimg = 'transexual.gif';
                break;
            case 3:
                $gendertxt = $txt['transm2f'];
                $genderimg = 'transexual.gif';
                break;
            case 2:
                $gendertxt = $txt['female'];
                $genderimg = 'Female.gif';
                break;
            case 1:
                $gendertxt = $txt['male'];
                $genderimg = 'Male.gif';
                break;
            default:
                $gendertxt = '';
                break;
        }
Title: Re: Genders
Post by: Sir Osis of Liver on April 20, 2017, 06:00:58 PM
Nice fix.  Can you get the mod updated?
Title: Re: Genders
Post by: Linkjay on April 20, 2017, 08:29:28 PM
Quote from: Sir Osis of Liver on April 20, 2017, 06:00:58 PM
Nice fix.  Can you get the mod updated?

8 years. Unlikely.

Hopefully someone will come in and make the edits and re-release.
Title: Re: Genders
Post by: KriKa on April 24, 2017, 01:39:14 AM
Quote from: bestnow on April 20, 2017, 07:28:35 AM
FILE: Load.php  LINE: 1140  (Sources file)
find:

// Set things up to be used before hand.
$gendertxt = $profile['gender'] == 2 ? $txt['female'] : ($profile['gender'] == 1 ? $txt['male'] : '');


replace:

$gendertxt = $profile['gender'] == 2 ? $txt['female'] : $profile['gender'] == 1 ? $txt['male'] : ($profile['gender'] == 3 ? $txt['transgender'] : '') ;



FILE: Profile-Modify.php LINE: 305 (Sources file)

find:

'options' => 'return array(0 => \'\', 1 => $txt[\'male\'], 2 => $txt[\'female\']);',

replace:

'options' => 'return array(0 => \'\', 1 => $txt[\'male\'], 2 => $txt[\'female\'],  3 => $txt[\'transgender\']);',


FILE: index.english LINE 170 (Themes/default/languages file)
find:

$txt['female'] = 'Female';

add below

$txt['transgender'] = 'Transgender';










EXTRA INFO PICTURE GENDER if u want to add:



file: load.php LINE: 1180

Ex how the line looks like:

'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''









picture to see it finish:
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Foi67.tinypic.com%2F2lawi85.jpg&hash=6c7060904dd158d1b667ae0d4d6c248ceae431dd)
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Foi67.tinypic.com%2F103zqlw.jpg&hash=c3ec8e7a13dec35c7212470f144d0a5920147e21)
awesome i was talking about it in another forum(forum of a MMORPG i paly)
i made a sugegstion for it, i will say it in...

Its pretty good to have
Male
Female
Lesbian
Gay
Trans

:D sounds good no?

@Btw i loved it, im lesbian and for long time i was thinking about it.
Title: Re: Genders
Post by: Linkjay on April 24, 2017, 01:53:28 AM
Quote from: KriKa on April 24, 2017, 01:39:14 AM
Quote from: bestnow on April 20, 2017, 07:28:35 AM
--snip--
awesome i was talking about it in another forum(forum of a MMORPG i paly)
i made a sugegstion for it, i will say it in...

Its pretty good to have
Male
Female
Lesbian
Gay
Trans

:D sounds good no?

@Btw i loved it, im lesbian and for long time i was thinking about it.

You should always snip away text from a really big quote because it becomes absurdly large when it is really unnecessary to include all that.

I digress.

I think if you were going to add more genders, it should not include Gay or Lesbian because those are not genders but simply sexual preferences. That could be put into another field, however.
Title: Re: Genders
Post by: KriKa on April 24, 2017, 01:58:22 AM
you right but its the point im meaning
Title: Re: Genders
Post by: Arantor on April 24, 2017, 02:40:22 AM
Personally I'd disable the inbuilt one and convert it to a custom field then you could add as many as desired.

Going to the previous point of debate, there is a distinction between sex and gender, and there is a difference between gender identity and sexual preference, and without wanting to sound uninclusive, gay and lesbian do not belong in a gender identity choice in this context.

Being gay does not change being male just as being a lesbian does not change being female. It also doesn't affect whether a man or woman identifies with the biology they have, e.g. a straight woman can assume something of a male gender identity because gender fluidity is a massively complex thing.
Title: Re: Genders
Post by: Linkjay on April 24, 2017, 04:11:49 AM
Quote from: Arantor on April 24, 2017, 02:40:22 AM
Personally I'd disable the inbuilt one and convert it to a custom field then you could add as many as desired.

Going to the previous point of debate, there is a distinction between sex and gender, and there is a difference between gender identity and sexual preference, and without wanting to sound uninclusive, gay and lesbian do not belong in a gender identity choice in this context.

Being gay does not change being male just as being a lesbian does not change being female. It also doesn't affect whether a man or woman identifies with the biology they have, e.g. a straight woman can assume something of a male gender identity because gender fluidity is a massively complex thing.

Could not agree more with quite literally every word said in that passage.
Title: Re: Genders
Post by: Kindred on April 24, 2017, 06:57:49 AM
also, please note that the one you quoted from "best now" does miss at least one location/file that also needs to be changed... hence my suggestion to use the mod with the noted changes - which accounts for all locations and more easily allows your own updates.

finally... yes...  As Arantor says, gender identity is separate and individual from sexual preference.
Additionally, while I may be interested in what gender an individual identifies as within a community (after all, I would like to know what pronoun preference to use, for one thing), unless your community needs that infiormation, sexual preference really has no place in being identified to the world.
Title: Re: Genders
Post by: Jennifer RachaelAnn on April 25, 2017, 07:22:12 PM
Wow, I think that's the most stuff I didn't understand all at once. I have no idea what any of that coding stuff is. I guess I'm screwed for adding the fields?
Title: Re: Genders
Post by: Linkjay on April 25, 2017, 08:30:45 PM
You could use the help wanted section or mod requests. You could also go as far as using a freelancer for hire site to do that.
Title: Re: Genders
Post by: shawnb61 on April 25, 2017, 08:59:09 PM
The custom fields solution requires no code, though it is limited in where identity is displayed.
Title: Re: Genders
Post by: Kindred on April 25, 2017, 10:32:31 PM
Do what i said...   apply the mod
Then fix the one code which failed the auto check, as indicated...

If you want more options, then add cases within the list of case statements



Quote from: Kindred on April 20, 2017, 08:36:37 AM
Actually, this mod
https://custom.simplemachines.org/mods/index.php?mod=2152

will almost install on 2.0.13, if you emulate "SMF 2.0 RC2" (no quotes)
the only failure is in Load.php for the image
The fix?
Install the mod and then make this specific change

Code (in Load.php, find) Select

'image' => !empty($profile['gender']) ? '<img class="gender" src="' . $settings['images_url'] . '/' . ($profile['gender'] == 1 ? 'Male' : 'Female') . '.gif" alt="' . $gendertxt . '" />' : ''
   

Code (replace with ) Select

'image' => !empty($profile['gender']) ? '<img src="' . $settings['images_url'] . '/' . $genderimg . '" alt="' . $gendertxt . '" border="0" />' : ''



the nice thing about this mod is that it becomes fairly easy to change or add the choices -- just change the case statements as were added (see below) and then add additional images for each representation
Code (in Load.php) Select

switch($profile['gender']) {
            case 5:
                $gendertxt = $txt['intersexed'];
                $genderimg = 'intersexed.gif';
                break;
            case 4:
                $gendertxt = $txt['transf2m'];
                $genderimg = 'transexual.gif';
                break;
            case 3:
                $gendertxt = $txt['transm2f'];
                $genderimg = 'transexual.gif';
                break;
            case 2:
                $gendertxt = $txt['female'];
                $genderimg = 'Female.gif';
                break;
            case 1:
                $gendertxt = $txt['male'];
                $genderimg = 'Male.gif';
                break;
            default:
                $gendertxt = '';
                break;
        }

Title: Re: Genders
Post by: bestnow on April 26, 2017, 04:16:00 AM
Quote from: shawnb61 on April 25, 2017, 08:59:09 PM
The custom fields solution requires no code, though it is limited in where identity is displayed.

Beta version of mod that Kindred send,


--edit: attachment removed
Title: Re: Genders
Post by: Arantor on April 26, 2017, 04:37:58 AM
Still don't get why custom fields aren't being used, requires no code change at all.
Title: Re: Genders
Post by: Kindred on April 26, 2017, 08:21:48 AM
that is true....  custom fields could be used as well, with no coding.
I just went the route of the mod because it uses the existing gender field in the user record... but if you never plan to do any additional logic on the field, then I guess custom fields would be easier, indeed.

bestnow - I have removed your attachment.
1- the original mod license does not allow redistribution or modification. Giving instruction on HOW to modify it is not a violation, but packaging that modification and claiming it with your own copyright is a violation.

2- adding your copyright to the SMF copyright line like that is a violation of our mod design guidelines
Title: Re: Genders
Post by: Arantor on April 26, 2017, 11:50:05 AM
FYI the gender field in 2.1 is already a custom field.
Title: Re: Genders
Post by: shawnb61 on April 26, 2017, 12:22:44 PM
Quote from: Arantor on April 26, 2017, 04:37:58 AM
Still don't get why custom fields aren't being used, requires no code change at all.

I think the concern here is that, without customization, the custom field isn't displayed on posts in 2.0. 

Not an issue with 2.1, which handles this quite nicely, as you point out. 

IMO, dealing with the custom field limitation in 2.0 in the meanwhile may be a good compromise, & wait for 2.1 for improved visibility. 

Looking ahead, I'm not sure I'd want to utilize the mod, as I am not sure what the 2.1 migration ramifications would be without testing it extensively (maybe I'm being too paranoid & assuming it won't come over cleanly...).  I'd hate to lose the detail, or, require custom one-off code to migrate it properly with images, etc. 

I would definitely go with custom fields & wait for 2.1 for the visibility.
Title: Re: Genders
Post by: Arantor on April 26, 2017, 12:54:17 PM
What improved visibility?

The GitHub field on posts like yours and mine is a custom field!
Title: Re: Genders
Post by: Sir Osis of Liver on April 26, 2017, 01:13:38 PM
Quote from: Sir Osis of Liver on April 19, 2017, 11:52:48 PM
If custom fields are used, gender will not be displayed in poster info panel in display template.  Would require some custom coding to do that.

I was incorrect. :P  Custom profile field is displayed in poster info if Show on Topic View: is checked in custom field settings.
Title: Re: Genders
Post by: Kindred on April 26, 2017, 01:18:30 PM
yup....
Title: Re: Genders
Post by: shawnb61 on April 26, 2017, 03:15:56 PM
In other words, there is no lost functionality at all using custom fields.   

Sorry, I missed that. 

"Toto, we've been in Kansas all along!"
Title: Re: Genders
Post by: Sir Osis of Liver on April 26, 2017, 10:25:20 PM
Actually, it's in the screenshot you posted earlier, but I don't see very well and missed it.
Title: Re: Genders
Post by: shawnb61 on April 27, 2017, 01:16:31 AM
Jennifer Rachael Ann -

Do you think you could follow the examples in the pictures in Reply #8 above?

No coding.  Just configuring the custom fields.  Let us know if you need further detail/explanation.