• [MOD] Dropdown options for custom database fields 4 0 5 1
Currently:  

Author Topic: [MOD] Dropdown options for custom database fields  (Read 199062 times)

0 Members and 1 Guest are viewing this topic.

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: [MOD] Dropdown options for custom database fields
« Reply #15 on: May 29, 2005, 07:07:05 AM »
What would the drop down look like in the uploadform.html template?

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: [MOD] Dropdown options for custom database fields
« Reply #16 on: May 29, 2005, 07:42:57 AM »
See... I want the field required, but that initial --- entry is being accepted.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #17 on: May 29, 2005, 07:58:09 AM »
What would the drop down look like in the uploadform.html template?
thats a basic HTML knowlege u should have ;)

See... I want the field required, but that initial --- entry is being accepted.
that is controled by information u entered in db_field_definitions.php (read comments in that file for more info)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: [MOD] Dropdown options for custom database fields
« Reply #18 on: May 29, 2005, 08:41:16 AM »
Isn't working :(

Nothing I try with that db_field_definitions.php even gets put into the database :(

Offline Warrior

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
    • Lawrence Family History
Re: [MOD] Dropdown options for custom database fields
« Reply #19 on: May 29, 2005, 09:34:41 AM »
Ok.. I should go ahead and take myself out behind the barn and beat myself with a 2x4... or shoot myself.

Database field had a space before its name.

...oye  :roll:

drhtm

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #20 on: June 08, 2005, 03:17:00 AM »
great mod!

what if I want to add different language to display in the dropdown, for example, i want english and french so the options in the dropdown will conform to the language selected by the user. is this possible?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #21 on: June 08, 2005, 03:27:27 AM »
put your array into $lang['somename'] variable and put into your main.php files (language files)
so, the result would looks something like this:
db_field_definitions.php:
Quote
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, $lang['user_gender_array'], 0, 1, 5, 0);
main.php:
Quote
$lang['user_gender_array'] = array("---", "male", "female");
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #22 on: June 08, 2005, 05:31:53 AM »
put your array into $lang['somename'] variable and put into your main.php files (language files)
so, the result would looks something like this:
db_field_definitions.php:
Quote
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, $lang['user_gender_array'], 0, 1, 5, 0);
main.php:
Quote
$lang['user_gender_array'] = array("---", "male", "female");

that's beautiful.  it works as promised, however, one problem i notice is that if i edit my profile while my site is in english and I save the information, then if i switch to french, and view my profile, the english text is displayed instead of the french one.  any ideas?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #23 on: June 08, 2005, 06:02:57 AM »
it depence on how u save the information into the database.
I'd suggest to use multi-dimention arrays:
Code: [Select]
array(
  0 => "---",
  1 => "male",
  2 => "female"
);
so in the database would save numbers (array keys) instead of values.
That way u can use trully mult-language text. (please read more about how to use multi-dim arrays in the original topic.)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #24 on: June 08, 2005, 01:50:05 PM »
it depence on how u save the information into the database.
I'd suggest to use multi-dimention arrays:
Code: [Select]
array(
  0 => "---",
  1 => "male",
  2 => "female"
);
so in the database would save numbers (array keys) instead of values.
That way u can use trully mult-language text. (please read more about how to use multi-dim arrays in the original topic.)

oh yes, i see.  I read the orginal topic and it makes sense now.  However, if the user selects male, then the '1' will be saved in the database.  How do I retrieve it in the members profile so it will display 'male' in english or french?  I don't think I understand that part...

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #25 on: June 08, 2005, 02:07:43 PM »
something like:
$lang['user_gender_array'][$user_info['user_gender']]
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #26 on: June 08, 2005, 02:38:55 PM »
wait, now i'm confused.

Step by step.
from includes/db_field_definitions.php
I add
Code: [Select]
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, $lang['user_gender_array'], 1, 0, 0, 0);
In the language files (main.php)

I add in the english main.php
Code: [Select]
$lang['user_gender_array'] = array("0" => "------", "1" => "Male", "2" => "Female");
 I add in the french main.php
Code: [Select]
$lang['user_gender_array'] = array("0" => "------", "1" => "Mâle", "2" => "Femelle");
and then? in the members_profile.html template I add?????? So it will display 'female' when it's english and 'femelle' when its french...

Code: [Select]
$lang['user_gender_array'][$user_info['user_gender']] doesn't make sense to me. I'm sorry.


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Dropdown options for custom database fields
« Reply #27 on: June 08, 2005, 02:46:32 PM »
actualy in members_profile.html u should not change anything...update your pforile again and it should be ok.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

drhtm

  • Guest
Re: [MOD] Dropdown options for custom database fields
« Reply #28 on: June 08, 2005, 02:57:14 PM »
hmmm....

I use this in my template {user_gender} and it displays '1'...?

Offline Stryker

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • http://www.3dm-mc.com
Re: [MOD] Dropdown options for custom database fields
« Reply #29 on: June 22, 2005, 12:52:36 AM »
I need make checkbox for custom database fields. Like this: <input type="checkbox" name="checkbox" value="checkbox">

Please, help me. Thanks