Page Index Toggle Pages: [1] 2 3 4 Send TopicPrint
Very Hot Topic (More than 25 Replies) Adding new fields to member profile (Read 14437 times)
Administrator
Forum Administrator
*****
Offline


Yummm

Posts: 7
Location: Modders Rile
Joined: Oct 7th, 2014
Gender: Male
Adding new fields to member profile
Jul 31st, 2001 at 1:07am
Print Post  
This tutorial has been created by Gerlando - thx for your work!

First, you will want to open up "english.lng" Look for this line
Code
Select All
$txt{'749'} = "The 'number of posts' box can only contain digits."; 



and place your new item name here after this line, like so.
Code
Select All
$txt{'750'} = "Car Info"; 



Now update this line near the top.
Code
Select All
keys(%txt) = 749; 



to your new number count...
Code
Select All
keys(%txt) = 750; 



Now open up your "load.pl.

Look for
Code
Select All
$userprofile{$user}->[9] = $userprofile{$user}->[9] ? qq~<a href="aim:goim?screenname=$userprofile{$user}->[9]&message=Hi.+Are+y
ou+there?"><img src="$imagesdir/aim.gif" alt="$userprofile{$user}->[9]" border="0"></a>~ : ''; 


     
and add
Code
Select All
$userprofile{$user}->[20] = $userprofile{$user}->[20] ? qq~<font size="1">$txt{'750'}: $userprofile{$user}->[20]<br>~ : ''; 


     
Now open up your "profile.pl.

Look for:
Code
Select All
<tr>
      <td width="320"><font size=2><b>$txt{'231'}: </b></font></td>
      <td>
      <select name="gender" size="1">
       <option value=""></option>
       <option value="Male"$GenderMale>$txt{'238'}</option>
       <option value="Female"$GenderFemale>$txt{'239'}</option>
      </select>
      </td>
      </tr> 



and add the following code BEFORE the code above.
Code
Select All
<tr>
      <td width="320"><font size=2><b>$txt{'750'}: </b></font></td>
      <td><font size=2><input type="text" name="carinfo" size="50" value="$memsettings[20]"></font></td>
      </tr> 



then look for
Code
Select All
     </tr><tr>
        <td><font size=2><b>$txt{'96'}: </b></font></td>
        <td><font size=2><a href="$memsettings[4]" target=_blank>$memsettings[3]</a></font></td>
      </tr><tr>
      <td colspan="2"><hr size="1" width="100%" color="$color{'windowbg3'}" class="windowbg3"></td>
      </tr> 



and add
Code
Select All
<tr>
      <td><font size=2><b>$txt{'750'}: </b></font></td>
      <td><font size=2>$memsettings[20]</font></td>
      </tr> 



then look for
Code
Select All
&ToHTML($member{'name'});  



and add this on the next line
Code
Select All
&ToHTML($member{'carinfo'});  



then look for
Code
Select All
print FILE "$FORM{'hideemail'}\n"; 



and add this on the next line
Code
Select All
print FILE "$member{'carinfo'}\n"; 



Upload those files and vola! Now if you would like the new field shown in the actual posts you need to edit display.pl

Look for this line:
Code
Select All
$memail = $userprofile[2]; 



and add:
Code
Select All
$carinfo = $userprofile[20]; 



then look for:
Code
Select All
print << "EOT";
            $star<br><BR>
            $userprofile[11]
            $postinfo

[b]and add:[/b]
$carinfo
  



Ok,... I think that's it! It's really a lot easier then I probably made it out to be. Basically you are adding a new array element which happens to correspond to the # of lines in a members .dat file. The default set up has 20 lines so we're adding a 21st line. The element is automatically added to the array at the time the script runs so you can easily access it.

  

The Administrator.
Back to top
WWW  
IP Logged
 
Dave Baughman
God Member
*****
Offline


I want my MTV

Posts: 2039
Location: Murfreesboro
Joined: May 18th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #1 - Jul 31st, 2001 at 1:09am
Print Post  
Remember, if you install mods which also modify the number of elements in the username.dat files for your users, you will need to change the mod a little bit so that it doesnt overwrite your extra member settings and instead prints after them in the username.dat files.
  

I'm not sure if it's ignorance or apathy, but I don't know and I don't care.
Back to top
WWW  
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #2 - Aug 13th, 2001 at 8:27am
Print Post  
my next mod is gonna add to username.dat files..
how do i make y mod compat with others?
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Dave Baughman
God Member
*****
Offline


I want my MTV

Posts: 2039
Location: Murfreesboro
Joined: May 18th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #3 - Aug 13th, 2001 at 4:19pm
Print Post  
make a username.om file (om = omario) and whenever you add information to username.dat's, just keep adding them to the .om file instead. This prevents any mod incompatibilities as far as file structure. When you release a second mod that also uses that om file, you'll need to make a small patch for it to work if they already have your first mod installed, but you are still just dealing with all your own coding and not having to worry about someone else's stuff, so this keeps it simple. Adding one more file isnt a big deal, anyway. The information is going to take up just as much room in the dat file, so you might as well put it into another file and keep it organized.

- DaveB
  

I'm not sure if it's ignorance or apathy, but I don't know and I don't care.
Back to top
WWW  
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #4 - Aug 13th, 2001 at 7:05pm
Print Post  
good explanation dave, and thanks a load!
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #5 - Aug 13th, 2001 at 10:54pm
Print Post  
wait, so i would have to change a lot of the ocde   above wouldn't i, and put the om file on load.pl, and stuff?
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #6 - Aug 13th, 2001 at 11:00pm
Print Post  
ignore last post...
dave, r there any mods that i can look at that do what u say in ur last post?
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Dave Baughman
God Member
*****
Offline


I want my MTV

Posts: 2039
Location: Murfreesboro
Joined: May 18th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #7 - Aug 13th, 2001 at 11:36pm
Print Post  
not really. It depends. If you are storing information pertaining to a user but the info isnt editable by the user as just another profile field (, ie, if you wanted to store the number of posts they made with more than 100 charaters in it) then you dont have to make it load with load.pl, you just read out of it wherever you need it. If it is going to be displayed in the profile, you just have to add in some other routines for opening and reading (and writing to that file, if they are editing their profile). The load.pl is the way it is because it uses some hashes and arrays to make things easy in the default YaBB. If your mod was in a final release of YaBB, it'd be that way, too. But instead of sticking it into that user hash, you're just going to have to read it seperately. Not that big a deal, really. Dont think too much about it cause you'll just confuse yourself. Just read and write from the file wherever you need to the same way you always would.

Also, a side note to the tutorial above...

In place of that english.lng modification, you should find
Code
Select All
1;
 



(it's the last line in english.lng) and then do an add before and make your own hash. For example, for a mod named "new users mod" with five things of text, I'd do an add before and put in:

Code
Select All
key(%nutxt) = 5;
$nutxt{'1'} = "Whatever text1";
$nutxt{'2'} = "Whatever text2";
$nutxt{'3'} = "Whatever text3";
$nutxt{'4'} = "Whatever text4";
$nutxt{'5'} = "Whatever text5";
 



This helps prevent mod incompatibilities because of english.lng editing.

- DaveB
  

I'm not sure if it's ignorance or apathy, but I don't know and I don't care.
Back to top
WWW  
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #8 - Aug 13th, 2001 at 11:53pm
Print Post  
i'm lazy and for this versionit is just gonna add to username.dat...
it is getting really hard though  :s02:
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Shoeb Omar
God Member
*****
Offline


Mod Writer

Posts: 5665
Location: San Diego
Joined: Jun 29th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #9 - Aug 13th, 2001 at 11:56pm
Print Post  
uh oh,
i tried this but it doesnt seem to stor my new field in memsettings20 even though this is a clean yabb....
Instead it stores it on the 12th line of username.dat...
  

YaBB SP2 BETA!
Now taking pay jobs in PHP or Perl.  Contact me for details.
Back to top
IP Logged
 
Dave Baughman
God Member
*****
Offline


I want my MTV

Posts: 2039
Location: Murfreesboro
Joined: May 18th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #10 - Aug 14th, 2001 at 1:14am
Print Post  
lazy = bad mods that people dont like because they arent compatible. =P  If you wish to continue this discussion, start it over at the ideas board. This post is for comments on the tutorial.
  

I'm not sure if it's ignorance or apathy, but I don't know and I don't care.
Back to top
WWW  
IP Logged
 
pet_ffm
New Member
*
Offline


I am a Rookie

Posts: 32
Joined: Sep 25th, 2001
Gender: Female
Re: Adding new fields to member profile
Reply #11 - Sep 25th, 2001 at 8:09am
Print Post  
Hi, the idea with the additional field is great !! I would need that too, but in my case the additional field should be uneditable for the user, only the admin should be able to alter it.
Does anybody have  a solution for that ?

I am a novice and a girl but I managed to get the cgi version running with 2 mods (birthday and chat, chat not working 100%...) in the first attempt.

thanks in advance
  

webmistress of http://www.surfxchange.net. Or to go straigh to the forum, click here:
http://www.surfxchange.net/cgi-bin/YaBB/YaBB.cgi
Back to top
WWWYIM  
IP Logged
 
tau3
New Member
*
Offline


I love YaBB 1 Gold!

Posts: 2
Joined: Oct 16th, 2001
Re: Adding new fields to member profile
Reply #12 - Oct 18th, 2001 at 12:17am
Print Post  
First, I wanna say this is a great thread.. but I'm still a little confused and I want to make sure I'm doing everything I need to do before I start mod-ing...

Heres what I want to do:
Add 3 fields (first, last, class) to the member profile, such that the user MUST enter in those fields when they first register for the forum AND that the information for those fields shows up in both the Profile and in posts (like under the number of posts)..

Can someone please outline all the pages that would be involved in this modification??

Thanks! Help is much appreciated.
  
Back to top
 
IP Logged
 
McH
Junior Member
**
Offline


Juud. 16

Posts: 60
Location: Lahti
Joined: Nov 6th, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #13 - Nov 6th, 2001 at 6:34am
Print Post  
Why i need to ad "keys(%txt) = 750;"  :s03:
  
Back to top
WWW  
IP Logged
 
salesplaza
Full Member
***
Offline


SalesPlaza is the one
!

Posts: 116
Joined: Jul 22nd, 2001
Gender: Male
Re: Adding new fields to member profile
Reply #14 - Nov 6th, 2001 at 7:52pm
Print Post  
When I let the info be put on the 30th line in the .dat , it shows up on the 21st line.

How come ?!
  

Don't look any further ! You've already found us !
Back to top
WWWICQ  
IP Logged
 
Page Index Toggle Pages: [1] 2 3 4
Send TopicPrint