Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2001, 04:36 PM
Justice's Avatar
Justice Justice is offline
 
Join Date: Oct 2001
Location: New Orleans
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd like to be able to make a custom profile field a drop down menu or button select instead of just a text input. There are certain fields that I need to restrict my users to only a select few choices. In UBB, every extra field was manually added through hacks, but vB creates them automatically. While this saves a lot of time, it also leaves me with less control.

An example of this would be using "Gender" as a custom field, and only having 'male' or 'female' as selectable choices, so they couldn't type in "transsexual" or something.

I have a few fields that I'd need a pull down menu for. How would I set that up?

(It seems like every time I post a "How Do I" question, I get the feeling it belongs in the hack request forum, but I'm not really sure)
Reply With Quote
  #2  
Old 09-25-2001, 08:32 PM
Freddie Bingham's Avatar
Freddie Bingham Freddie Bingham is offline
 
Join Date: Oct 2001
Posts: 506
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have no less control with our system. You can hack the user table and add all the fields you want and the accompanying html/php to support it. Just look how the www or icq fields are handled.

Expanding the field types is on the todo list though.
Reply With Quote
  #3  
Old 09-26-2001, 02:04 AM
Justice's Avatar
Justice Justice is offline
 
Join Date: Oct 2001
Location: New Orleans
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by freddie
Just look how the www or icq fields are handled.
That's the first thing I did, believe me. I opened member.php and looked at the routines for other fields...

PHP Code:
if ($userinfo[icq]!="") {
    eval(
"\$userinfo[icqicon] = \"".gettemplate("icq")."\";");
  } else {
    
$userinfo[icq]=" ";
  } 
With the added custom fields, I have no idea what to replace between the [ ] brackets. It's not based on an assigned number, but some sort of other value. Any ideas?
Reply With Quote
  #4  
Old 09-26-2001, 05:35 AM
Justice's Avatar
Justice Justice is offline
 
Join Date: Oct 2001
Location: New Orleans
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i guess what I'm asking is.. how do I pull a custom field value directly from the database, just like the default fields (aim, icq, www, birthday, etc.)?? I want to be able to plug in custom field values anywhere I want, instead of $customfields doing my dirty work for me. This would really help me create my registration, edit profile, and view profile pages.

Any (specific) tips would be appreciated
Reply With Quote
  #5  
Old 09-26-2001, 06:31 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So you want a drop down field right?
Alrighty.

Part 1

First of all we will take care of the modifyprofile template.
In there, add something like this:
Code:
<tr>
	<td bgcolor="{secondaltcolor}"><normalfont><b>Are you a male of a female?</b></normalfont></td>
	<td bgcolor="{secondaltcolor}"><smallfont>
	<select name="sex">
		<option value="dunno" $sexsel[dunno]>I don't know yet.</option>
		<option value="male" $sexsel[male]>Male.</option>
		<option value="female" $sexsel[female]>Female.</option>
	</select></smallfont></td>
</tr>
(But of course change {secondaltcolor} to {firstaltcolor}, depends on where you put this, what's before, what's after, etc.)

See the $sexsel[xxx] variable I put in each option?
This is so that when a use comes back to the profile page, what he selected before will show up selected on this page. So he won't have to change this value every time he changes his profile.

The $sexsel[xxx] (sex+selected) is set in the member.php page.
Where?
Somewhere in this block:
PHP Code:
// ############################### start modify profile ###############################
if ($action=="editprofile") {
  ...
  ...
  ...
  eval(
"dooutput(\"".gettemplate("modifyprofile")."\");");

So we're gonna add this:
PHP Code:
  if ($bbuserinfo[sex]) {
    
$sexsel[$bbuserinfo[sex]]="selected";
  } else {
    
$sexsel[dunno]="selected";
  } 
right after this:
PHP Code:
  if ($allowsmilies) {
    
$smiliesonoff=$ontext;
  } else {
    
$smiliesonoff=$offtext;
  } 
(the IF is just in case the field is empty when the user changes his profile. Not really necessary, but we all like things organized()
What will this do?
$bbuserinfo[sex] is what the user currently has in his profile for the sex field.
So, if he has selected 'male' before, $sexsel[male] will contain the word "selected".
So when we put this in the <option> tag, it will cause that and only that option to be selected.
Note that the $sexsel[xxx] MUST match the value="xxx", or it just won't work.

Ok, so we took care of the end user stuff.
But how are we gonna insert this info into the database?

Part 2

So first of all, we need to create the field for that, in the user table.
For this example, we'll run this query:
Code:
ALTER TABLE user ADD sex VARCHAR(8) not null
I went for 8 since in this case the max value that can be is 'female' (6).

So, we need to add something to the query that updates the user profile, right?
This is the query, as it is now:
Code:
$DB_site->query("UPDATE user SET birthday='".addslashes($birthday)."',signature='".addslashes($signature)."',customtitle='$customtitle',usertitle='".addslashes($customtext)."',email='".addslashes(htmlspecialchars($email))."',parentemail='".addslashes(htmlspecialchars($parentemail))."',coppauser='$coppauser',homepage='".addslashes(htmlspecialchars($homepage))."',icq='".addslashes(htmlspecialchars($icq))."',aim='".addslashes(htmlspecialchars($aim))."',yahoo='".addslashes(htmlspecialchars($yahoo))."',usergroupid='$bbuserinfo[usergroupid]' WHERE userid='$bbuserinfo[userid]'");
So let's add this to the query:
Code:
$DB_site->query("UPDATE user SET birthday='".addslashes($birthday)."',signature='".addslashes($signature)."',customtitle='$customtitle',usertitle='".addslashes($customtext)."',email='".addslashes(htmlspecialchars($email))."',parentemail='".addslashes(htmlspecialchars($parentemail))."',coppauser='$coppauser',homepage='".addslashes(htmlspecialchars($homepage))."',icq='".addslashes(htmlspecialchars($icq))."',aim='".addslashes(htmlspecialchars($aim))."',yahoo='".addslashes(htmlspecialchars($yahoo))."',usergroupid='$bbuserinfo[usergroupid]',sex='".addslashes($sex)."' WHERE userid='$bbuserinfo[userid]'");
This will insert $sex ('dunno', 'male' or 'female') into the sex field in the user table.

Part 3

Now, let's take care of the registration process.
This is optional. You need to decide whether you want to include this when people register, or not. Your choice.
If you do want this, tell me and I'll explain this as well.


I hope you understand everything. If you still got questions, just ask.

(sorry about the width of this. Long queries, you know :P)
Reply With Quote
  #6  
Old 09-26-2001, 07:02 AM
ToraTora! ToraTora! is offline
 
Join Date: Nov 2001
Posts: 255
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

call me crazy, but isnt there a method of just hardcoding the drop down option in the main profile script? If I remember correctly, there was some hack here awhile back that allowed a person to add the option of choosing either a text field, drop down..etc..to the custom profile fields...Not that your way wont work firefly, it is just that I could of swore i added a drop down hack for user profiles onto our site at one time...worked slick, but lost it when i upgraded...
Reply With Quote
  #7  
Old 09-26-2001, 07:04 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I know what you mean.
I'll find the thread in a sec.
http://www.vbulletin.com/forum/showt...threadid=21833

But I remember that it uses flat files, which kinda sucks (IMO).

This is exactly how it's done with the other drop-down fields in vBulletin.
I dunno, but for me it looks like the easiest, cleanest way to do this.
I know it requires a bit hacking, but not TOO much of it.

Maybe a hack can be written to do this automatically...
Reply With Quote
  #8  
Old 09-26-2001, 07:13 AM
ToraTora! ToraTora! is offline
 
Join Date: Nov 2001
Posts: 255
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ah yes...thats rite...I had a +++++ of a time getting that one to work come to think of it..
Reply With Quote
  #9  
Old 09-26-2001, 07:26 AM
Justice's Avatar
Justice Justice is offline
 
Join Date: Oct 2001
Location: New Orleans
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by FireFly
This is optional. You need to decide whether you want to include this when people register, or not. Your choice.
If you do want this, tell me and I'll explain this as well.
I would like gender to be a registration option, yes.
thanks for explaining this all. 2 questions though...

1) If I add this to my vB now, it wouldn't cause problems when I import users from UBB, would it?

2) Why do I need to add the extra field from the database, instead of the control panel? Is that using a totally seperate table from the other custom fields?
Reply With Quote
  #10  
Old 09-26-2001, 07:32 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) I really can't tell, sorry. I'm not familiar with UBB, at all, and neither with the importer.
But still, I don't think you should have any problems. The field will just be blank.
I dunno, sorry.

2) First of all, when you add a field from the contorl panel, it still adds it to the database.
And if you add it from the control panel, it would be:
- a) in a different table.
- b) it will automatically show up with the rest of the custom fields, scuh as location, biography, etc.

I'll work on part 3.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:04 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05842 seconds
  • Memory Usage 2,277KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (4)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete