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 :: Polls :: Message Navigator
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 14:38 Go to next message
math_adm is currently offline  math_adm   France
Messages: 126
Registered: September 2003
Location: France
Karma: 0
Senior Member
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 21:23 Go to previous messageGo to next message
Abraxa is currently offline  Abraxa   Germany
Messages: 72
Registered: August 2004
Location: Germany
Karma: 0
Member
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 21: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 09: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
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 15:18 Go to previous message
JamesS is currently offline  JamesS   United States
Messages: 275
Registered: July 2002
Location: Atlanta, GA
Karma: 0
Senior Member
This is one area where LDAP support would be handy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: the login procedure
Next Topic: How to configure procmail
Goto Forum:
  

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

Current Time: Sun Jun 02 07:09:58 GMT 2024

Total time taken to generate the page: 0.23442 seconds