FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » I need a popup with a list of choices for user profile at register time
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
I need a popup with a list of choices for user profile at register time [message #21119] Mon, 15 November 2004 09:38 Go to next message
math_adm is currently offline  math_adm   France
Messages: 126
Registered: September 2003
Location: France
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Hello

Since we use the forum in a school, I need a field in the profile of each user to identify the class in which he belongs to (or "maths teacher" etc.). I chose to use (and rename) the "Occupation" field.

However, most users fill this field in their profile with heterogeneous content, making it difficult for me to filter. I would like to offer to them a list of choices for this field at register time, a function that would fill "Occupation" appropriately from a list displayed to the user.

This information would (should) be editable the usual way later by editing the profile, I just need this at register time.

Could anyone code this please ? please ? Very Happy

Thanks Wink
Re: I need a popup with a list of choices for user profile at register time [message #21127 is a reply to message #21119] Mon, 15 November 2004 16:23 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   Germany
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
add to buddy list
ignore all messages by this user
To achieve that you need to make changes to the register.tmpl and register.t files that can be found in /FUDforumData/thm/default/tmpl/ and /FUDforumData/src/, respectively.

In register.tmpl, replace the occpuation table row

<tr class="RowStyleA"><td>{MSG: register_occupation}</td><td><input type="text" name="reg_occupation" value="{VAR: reg_occupation}"maxlength=255 size=30></td></tr>


by

<tr class="RowStyleA"><td>The class you belong to:</td><td><select name="reg_occupation">{TEMPLATE-DATA: class_select_entries}</select></td></tr>




Then add the follwing near the end of register.t - right below all those "$blabla = tmpl_draw_radio_opt(...)" entries:

	$classes = array('Computer Science I'	=> 'CS1',
			'Computer Science II'	=> 'CS2',
			'Modern Arts'		=> 'MA',
			'Literature'		=> 'LI',
			'Calculus I'		=> 'CA1');

	foreach ($classes as $name => $value) {
		$values[] = $value;
		$names[]  = $name;
	}

	$values = implode("\n", $values);
	$names  = implode("\n", $names);
	$class_select_entries	= tmpl_draw_select_opt($values, $names, $uent->occupation, '{TEMPLATE: sel_opt}', '{TEMPLATE: sel_opt_selected}');


The code should be fairly self-explanatory, however there are a couple things to say:

a) the IDs for the classes (CS1, CS2, MA, ...) basically can be any combination of letters, numbers and underscores - spaces and apostrophes are a no-no Smile

b) since register.tmpl/.t is used for both registration of a new user and editing an existing user's profile, the changes made here will show up in both forms.

c) if you want to do things properly you should also edit the user profile so it doesn't show "Occupation: LI". You can do that by editing the usrinfo.tmpl and usrinfo.t files - if you don't need that functionality, go ahead and use what I posted above. If you however want to do things properly then things get a little more complicated (as always Smile). Not by much but I wanted to see if the simple version already does the trick for you or not. If not... let me know and I'll post the "proper" hack.

-Abraxa


PS: Almost forgot... as always when editing a .tmpl/.t file by hand you need to recompile the theme in order for the changes to become effective. You do that in your Admin CP under Theme Manager -> Rebuild Theme.

[Updated on: Mon, 15 November 2004 16:25]

Report message to a moderator

Re : Re: I need a popup with a list of choices for user profile at register time [message #21140 is a reply to message #21127] Tue, 16 November 2004 04:01 Go to previous messageGo to next message
math_adm is currently offline  math_adm   France
Messages: 126
Registered: September 2003
Location: France
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Thanks, I'll hack this in and tell you how it goes.

Thanks again, Razz

Frédéric.
Re: I need a popup with a list of choices for user profile at register time [message #21143 is a reply to message #21119] Tue, 16 November 2004 10:18 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
This is one area where LDAP support would be handy.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: the login procedure
Next Topic: How to configure procmail
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 17 04:03:25 EDT 2017

Total time taken to generate the page: 0.00695 seconds