|
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 |
Abraxa
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
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 ). 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
|
|
|
|
|