[Tutorial] How to add a new field to profile in 2.0.4

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
User avatar
Rod
Registered User
Posts: 232
Joined: Sun Dec 02, 2001 7:29 pm
Location: my chair, beside desk, in lounge, upstairs, in house, close to Farnham, just South of London, UK ...
Contact:

[Tutorial] How to add a new field to profile in 2.0.4

Post by Rod » Sun Mar 23, 2003 11:17 am

OK as people are still asking about this I've decided to do a new set of instructions for 2.0.4

They also have ability to edit the field in the admin section as requested somewhere.

The field is NOT compulsary when registering. But could be easily altered so that it is.

The field is viewable by everyone. It is easy to change it so only admins can view it if you wish.

I have used my real name mod as a basis so in this example the new field is for a real name.
Simply replace every instance of realname with whatever you want to call the field!

Here goes:


First you need to add a new column to your users table ...

Code: Select all

# 
#-----[ SQL ]------------------------------------------ 
# 
#	If you have a different table prefix then change this command accordingly.
#	I have used the default table prefix!
#
ALTER TABLE phpbb_users ADD user_realname VARCHAR (50)
Then you need to make it so that the user can input data into the new field when registering or changing profile. In this example the new field will be below the username. I'll tell you how to put it somewhere else later ...

Code: Select all

#
#----- [ OPEN ] -------------------------------------
#	This first section modifies registration and profile to input real name
includes/usercp_register.php

# 
#----- [ FIND ] ------------------------------------- 
# 
$strip_var_list = array('username' => 'username', 'email' => 'email', 'icq' => 'icq', 'aim' => 'aim', 'msn' => 'msn', 'yim' => 'yim', 'website' => 'website', 'location' => 'location', 'occupation' => 'occupation', 'interests' => 'interests');

# 
#----- [ IN-LINE, FIND ] ------------------------------------- 
# 
'username' => 'username', 
# 
#----- [ IN-LINE AFTER, ADD ] ------------------------------------- 
# 
 'realname' => 'realname',
#
#----- [ FIND ] -------------------------------------
#
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . "
#
#----- [ IN-LINE, FIND ] -------------------------------------
#
" . $avatar_sql . "
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, user_realname = '" . str_replace("\'", "''", $realname) . "'
#
#----- [ FIND ] -------------------------------------
#
			$sql = "INSERT INTO " . USERS_TABLE . "	(user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)

#
#----- [ IN-LINE, FIND ] -------------------------------------
#
user_allow_pm,
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
 user_realname,
#
#----- [ FIND ] -------------------------------------
#
				VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, ";

#
#----- [ IN-LINE, FIND ] -------------------------------------
#
$user_style, 0, 1,
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
 '$realname', 
#
#----- [ FIND ] -------------------------------------
#
# NOTE There are 2 instances of this add it for both!
$username = stripslashes($username); 
#
#----- [ AFTER, ADD ] -------------------------------------
#
$realname = stripslashes($realname); 

#
#----- [ FIND ] -------------------------------------
#
else if ( $mode == 'editprofile' && !isset($HTTP_POST_VARS['avatargallery']) && !isset($HTTP_POST_VARS['submitavatar']) && !isset($H 
TTP_POST_VARS['cancelavatar']) ) 
{ 
$user_id = $userdata['user_id']; 
$username = $userdata['username']; 

#
#----- [ AFTER, ADD ] -------------------------------------
#
$realname = $userdata['user_realname']; 

#
#----- [ FIND ] -------------------------------------
#
	display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat, $userdata['session_id']);

#
#----- [ IN-LINE, FIND ] -------------------------------------
#
$userdata['session_id']
#
#----- [ IN-LINE AFTER, ADD ] -------------------------------------
#
, $realname
#
#----- [ FIND ] -------------------------------------
#

$template->assign_vars(array( 
      'USERNAME' => $username, 

#
#----- [ AFTER, ADD ] -------------------------------------
#
      'REALNAME' => $realname, 

#
#----- [ FIND ] ----------------------------
#
		'L_EMAIL_ADDRESS' => $lang['Email_address'],

#
#----- [ AFTER, ADD ] -------------------------------------
#
		'L_REALNAME' => $lang['real_name'],
		'L_REALNAME_VIEWABLE' => $lang['real_name_viewable'],


#
#----- [ OPEN ] ------------------------------------- 
#
includes/usercp_avatar.php 

# 
#----- [ FIND ] ------------------------------------- 
# 
function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat, &$session_id)

# 
#----- [ IN-LINE, FIND ] ------------------------------------- 
# 
&$session_id
# 
#----- [ IN-LINE AFTER, ADD ] ------------------------------------- 
#
, &$realname
#
#----- [ FIND ] ------------------------------------- 
# 
   $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); 

# 
#----- [ IN-LINE, FIND ] ------------------------------------- 
# 
'dateformat'
# 
#----- [ IN-LINE AFTER, ADD ] ------------------------------------- 
# 
, 'realname'	
# 
#-----[ OPEN ]------------------------------------------ 
#	This section puts the entry field for a real name into registering
#	and into editing pofile.
# Remember to do this for every template you support
#
templates/subSilver/profile_add_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
	<tr> 
	<td class="row1" width="38%"><span class="gen">{L_USERNAME}: *</span></td>
	<td class="row2"><input type="text" class="post" style="width:200px" name="username" size="25" maxlength="40" value="{USERNAME}" /></td>
	</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	<tr> 
	  <td class="row1"><span class="gen">{L_REALNAME}: </span></td>
	  <td class="row2"> 
		<input type="text" class="post"style="width: 200px"  name="realname" size="25" maxlength="50" value="{REALNAME}" />
	  </td>
	</tr>
If you don't want below the username then simply but this last bit you add lower down. It's basic html. Make sure you put it after a

Code: Select all

</tr>
otherwise it will mess up your table.


Now you need to be able to let people view the new field. So let's put it into viewing the users profile. Currently it's below the username but can be moved using knowledge of basic html ...

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#
#
includes/usercp_viewprofile.php

# 
#-----[ FIND ]------------------------------------------ 
#
	'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '&',

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	'REALNAME' => ( $realname ) ? $realname : '&',

# 
#-----[ FIND ]------------------------------------------ 
#
//
// Generate page
//

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	$realname = $profiledata['user_realname'];

# 
#-----[ FIND ]------------------------------------------ 
#
	'L_INTERESTS' => $lang['Interests'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	'L_REALNAME' => $lang['real_name'],

# 
#-----[ OPEN ]------------------------------------------ 
#
# Remember to do this for every template you support
#
templates/subSilver/profile_view_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
		<tr> 
		  <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_JOINED}:&</span></td>

# 
#-----[ BEFORE ADD ]----------------------------------------
#
		<tr> 
		  <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_REALNAME}:&</span></td>
		  <td><b><span class="gen">{REALNAME}</span></b></td>
		</tr>
Now you need to edit your language file so that the user knows what the field is!
Here it is a real name field. You'll need to change the Real Name tag with somthing else!

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#
# Remember to do this for every language you support
# It needs translating!!!

language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
#

//
// Errors (not related to a
// specific failure on a page)
//
$lang['Information'] = 'Information';
$lang['Critical_Information'] = 'Critical Information';

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#

//
// Language variables for the New field Mod
//

$lang['real_name'] = 'Real Name';
Finally you will want to be able to edit the field when managing a user as an admin. Here's how to do it!
Once again this is put below the username. To move it it's simple HTML.

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
#
admin/admin_users.php

# 
#-----[ FIND ]------------------------------------------ 
#
		$username = ( !empty($HTTP_POST_VARS['username']) ) ? trim(strip_tags( $HTTP_POST_VARS['username'] ) ) : '';
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
		$realname = ( !empty($HTTP_POST_VARS['realname']) ) ? trim(strip_tags( $HTTP_POST_VARS['realname'] ) ) : '';

# 
#-----[ FIND ]------------------------------------------ 
#
			$username = stripslashes($username);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			$realname = stripslashes($realname);

# 
#-----[ FIND ]------------------------------------------ 
#
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . "

# 
#-----[ IN-LINE, FIND ]------------------------------------------ 
#
. $avatar_sql . "

# 
#-----[ IN-LINE AFTER, ADD ]------------------------------------------ 
#
, user_realname = '" . str_replace("\'", "''", $realname) . "'

# 
#-----[ FIND ]------------------------------------------ 
#
			$username = htmlspecialchars(stripslashes($username));

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			$realname = htmlspecialchars(stripslashes($realname));

# 
#-----[ FIND ]------------------------------------------ 
#
		$username = htmlspecialchars($this_userdata['username']);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
		$realname = htmlspecialchars($this_userdata['user_realname']);

# 
#-----[ FIND ]------------------------------------------ 
#
			$s_hidden_fields .= '<input type="hidden" name="username" value="' . str_replace("\"", "&", $username) . '" />';

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			$s_hidden_fields .= '<input type="hidden" name="realname" value="' . str_replace("\"", "&", $realname) . '" />';

# 
#-----[ FIND ]------------------------------------------ 
#
			'USERNAME' => $username,

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			'REALNAME' => $realname,

# 
#-----[ FIND ]------------------------------------------ 
#
			'L_USERNAME' => $lang['Username'],

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			'L_REALNAME' => $lang['real_name'],

# 
#-----[ OPEN ]------------------------------------------ 
#
templates/subSilver/admin/user_edit_body.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
	<tr> 
	  <td class="row1" width="38%"><span class="gen">{L_USERNAME}: *</span></td>
	  <td class="row2"> 
		<input class="post" type="text" name="username" size="35" maxlength="40" value="{USERNAME}" />
	  </td>
	</tr>

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
	<tr> 
	  <td class="row1" width="38%"><span class="gen">{L_REALNAME}: *</span></td>
	  <td class="row2"> 
		<input class="post" type="text" name="realname" size="35" maxlength="40" value="{REALNAME}" />
	  </td>
	</tr>
Thats it folks!!

It is possible to do the following:
  • View the new field in memberlist, viewtopic, usergroups etc.
  • Make the new field required when registering.
  • Make it so that a user cannot change the field when editing profile.
  • Make the new field only viewable by admins (as in the real name mod).
Hope all this helps people.
Rod [aka Kinger]
Dogs have owners, but cats have staff!

Mods
'Real Name' Mod here. Discussion here.
'Date/Time Last Visited' Mod here. Discussion here.

User avatar
smithy_dll
Former Team Member
Posts: 7630
Joined: Tue Jan 08, 2002 6:27 am
Location: Australia
Name: Lachlan Smith
Contact:

Post by smithy_dll » Sun Mar 23, 2003 12:18 pm

moved to mod authors support forum

and this post would make a great addition to the phpBB2 MODifications KB

JKeats
Registered User
Posts: 312
Joined: Thu Mar 20, 2003 12:32 am
Contact:

Post by JKeats » Tue Mar 25, 2003 6:14 am

This was a great mod! Worked for me! Actually I used the realname mod and just changed the real name to the field i wanted which was phone type (i have a cell phone forum).

I have a question though. Everything's working find... except a users avitar (when viewing posts in a thread) it says the following:

Joined: 15 Mar 2003
Posts: 173
Location: Southern Oregon
Modded i95cl

What I WANT it to say is:

Joined: 15 Mar 2003
Posts: 173
Location: Southern Oregon
Phone Type: Modded i95cl

Any ideas on what I missed and in what file I missed it?

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Tue Mar 25, 2003 1:33 pm

JKeats wrote: Any ideas on what I missed and in what file I missed it?

It could be a language entry (lang_main.php) or a template (tpl) item. My bet is that it's a language entry. I'm guessing 'cause I'm too lazy to go back and reread the entire thing. ;-)

If it's a language entry, simply look for the word "Modded" and replace it with appropriate text.

Dave
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

JKeats
Registered User
Posts: 312
Joined: Thu Mar 20, 2003 12:32 am
Contact:

Post by JKeats » Tue Mar 25, 2003 5:25 pm

i took a peek, and everything is added the way that the real name mod directed me to.

i can't seem to find an entry anyplace that would allow me to show my new field title (e.g. Phone Type: "bla bla" as opposed to just "bla bla")

any help would be greatly appreciated.

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Tue Mar 25, 2003 6:04 pm

Okay, you made me read the entire topic. ;-)

The mod listed above doesn't add data to viewtopic.php, so you must have done that yourself? I'm guessing?

Anyway, open viewtopic_body.tpl (it will be in your templates folder, i.e. ./templates/subSilver/viewtopic_body.tpl for subSilver) and find where you are displaying your new data. Just before that, add the text. It will be hard coded, but it will work. In other words, I'm guessing that you have an entry for {PHONETYPE} in your template. Make it look like this:

Code: Select all

Phone Type: {PHONETYPE}
and you should be good to go.

Alternatively you can make a language entry, set it in viewtopic.php, and pass it to the template to be displayed.

Dave
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

JKeats
Registered User
Posts: 312
Joined: Thu Mar 20, 2003 12:32 am
Contact:

Post by JKeats » Tue Mar 25, 2003 6:41 pm

thank you drathbun for your help.

although your suggestion regarding the viewtopicbody.tpl worked, when i do that, for some reason it removed the "new topic" and "post reply" button images from the page. :(

The ONLY line that currently has a reference to my new field (phonetype) in the viewtopicbody.tpl file is the following;

Code: Select all

<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a><b><a href="javascript:emoticon('[b]{postrow.POSTER_NAME}[/b], ')">{postrow.POSTER_NAME}</a></b></span><br /><span class="postdetails">{postrow.POSTER_RANK}<br />{postrow.RANK_IMAGE}{postrow.POSTER_AVATAR}<br /><br />{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}<br />{postrow.POSTER_PHONETYPE}</span><br /></td>
putting the text you suggested in there before the {postrow.POSTER_PHONETYPE} causes those two images to dissapear.

i don't know what i would need to add to the langmain.php file per your alternate suggestion.

as a side note... although i used this hack as a starting point... i used the instructions found here instead as they seemed to work a little better for my needs. sorry for my misscommunication before.

thanks anyway for your help. i hope this one can be figured out!

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Mar 26, 2003 3:58 am

Try this

Code: Select all

<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a><b><a href="javascript:emoticon('[b]{postrow.POSTER_NAME}[/b], ')">{postrow.POSTER_NAME}</a></b></span><br /><span class="postdetails">{postrow.POSTER_RANK}<br />{postrow.RANK_IMAGE}{postrow.POSTER_AVATAR}<br /><br />{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}<br />Phone Type: {postrow.POSTER_PHONETYPE}</span><br /></td>
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image

JKeats
Registered User
Posts: 312
Joined: Thu Mar 20, 2003 12:32 am
Contact:

Post by JKeats » Wed Mar 26, 2003 4:33 am

still makes those two images dissapear.

this is just plain crazy. i don't understand why those images are going away.

i even hacked it so that i have the "Phone:" field in the reg and user profile screens... and everything works great.

then i tried a modified version of the hack to view the interests and occupation fields in the viewtopic page (i just swaped out for the phone field) and STILL the two images dissapear.

i just don't get it.

thanks for your help though.

User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Post by drathbun » Wed Mar 26, 2003 5:41 am

Okay, I don't get it. You have the phone variable displayed, and everything works. You add the text, and the New Topic and Post Reply buttons are gone? They're not even in the same part of the table definition. Weird.

What is the javascript call for in your poster name? That's not part of the standard distribution.

JKeats
Registered User
Posts: 312
Joined: Thu Mar 20, 2003 12:32 am
Contact:

Post by JKeats » Wed Mar 26, 2003 4:50 pm

i have no clue. lol. i didn't add it myself, and the only mod i've installed that had it's own files was the file attatchment hack, and i'm pretty sure that that java ref isn't related to that, so i don't know what that is for.

it's no matter anyway. finally last night, i did something and it is now working fine. i have no idea what i did, but i did something and it worked.

lol.

i started from scratch again (i.e. on the backup files i made before i tried this mod the first time). i did the first part of the new field mod and simply got the new field into the registration screen, the edit profile screen, and the view profile screen. everything was working fine.

i tried to add the option to edit the new field in the admin panel, and that didn't work, so i put back the files from after the part of the hack that worked (that i mentioned before).

then i found the mod here to display the "interests" and "occupation" fields in the viewtopic screen. i simply swaped "interests" for my new field and did the mod for only ONE field. now this DIDN'T work at first, and i lost my post reply images (the two problem images) again. however, i realized that between the hacks/mods, i had TWO of the same $lang strings in my lang_main.php file that referenced the new field. i simply took one out and poof, everything worked fine.

i don't know if that was the problem before or not (i'm pretty sure i only had one $lang string before) but anyway... it's over and done now.

thanks a ton for trying to troubleshoot this with me. i really appreciate it.

User avatar
Rod
Registered User
Posts: 232
Joined: Sun Dec 02, 2001 7:29 pm
Location: my chair, beside desk, in lounge, upstairs, in house, close to Farnham, just South of London, UK ...
Contact:

Post by Rod » Thu Mar 27, 2003 10:20 pm

If you followed the real name mod you probably have in viewtopic.php a line like:

Code: Select all

$poster_phonetype = $postrow[£i]['user_phonetype'];
Try changing it to:

Code: Select all

$poster_phonetype = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? . 'Phonetype: ' . $postrow[$i][$user_phonetype'] : '';
I haven't tried it but it should work.
Rod [aka Kinger]
Dogs have owners, but cats have staff!

Mods
'Real Name' Mod here. Discussion here.
'Date/Time Last Visited' Mod here. Discussion here.

Duskette
Registered User
Posts: 118
Joined: Mon Jan 07, 2002 3:18 am
Location: Singapore
Contact:

Post by Duskette » Sat Mar 29, 2003 8:14 am

can we have the guide to adding another field to the viewtopic? call me stupid but i tried many times but only the "newfield:" appears but not the contents.

Hogyt
Registered User
Posts: 10
Joined: Thu Aug 08, 2002 10:10 am

Post by Hogyt » Mon Mar 31, 2003 1:17 am

I got the new field showing in viewtopic (under the joined, posts, location bit). It sounds like you might not have changed all the lines below so have a look at the changes I made and see if it works for you. This is the first time i've ever modded anything so if it doesn't work then sorry!

My new field was called province so change that in all the code below to whatever your field is called eg. if you followed this topic from the start then change it to realname except $lang['province'] will change to $lang['real_name'].

If anyone sees any mistakes please post!

Open viewtopic.php

Find

Code: Select all

//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
Inline find

Code: Select all

u.username,
After add

Code: Select all

u.user_province,
Find

Code: Select all

$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
After add

Code: Select all

$poster_province = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['province'] . ': ' . $postrow[$i]['user_province'] : '';
Find

Code: Select all

'POSTER_FROM' => $poster_from,
After add

Code: Select all

'POSTER_PROVINCE' => $poster_province,
Open viewtopic_body.tpl (for all templates you want modded)

Find

Code: Select all

<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a><b>{postrow.POSTER_NAME}</b></span><br /><span class="postdetails">{postrow.POSTER_RANK}<br />{postrow.RANK_IMAGE}{postrow.POSTER_AVATAR}<br /><br />{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}</span><br /></td>
Inline find

Code: Select all

<br />{postrow.POSTER_FROM}
After add

Code: Select all

<br />{postrow.POSTER_PROVINCE}

Duskette
Registered User
Posts: 118
Joined: Mon Jan 07, 2002 3:18 am
Location: Singapore
Contact:

Post by Duskette » Mon Mar 31, 2003 3:18 am

Hogyt wrote: I got the new field showing in viewtopic (under the joined, posts, location bit). It sounds like you might not have changed all the lines below so have a look at the changes I made and see if it works for you. This is the first time i've ever modded anything so if it doesn't work then sorry!

My new field was called province so change that in all the code below to whatever your field is called eg. if you followed this topic from the start then change it to realname except $lang['province'] will change to $lang['real_name'].

If anyone sees any mistakes please post!


thank you. it does work. :D

Post Reply

Return to “[2.0.x] MOD Writers Discussion”