Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: zknower on September 13, 2004, 02:27:16 PM

Title: Adding Fields to Profile template
Post by: zknower on September 13, 2004, 02:27:16 PM
Hi:

I previously requested how to remove fields (AIM, ICQ, etc) from the Profiles template and got very helpful responses. However, I now have two new questions:

1) How do I remove these same fields from the "Edit Profile" screen?

2) How can I add NEW fields to both the "Profile"  page and the "Edit Profile" page?

For example: I am setting up a forum for actors who went to grad school with me. I would like to be able to add:
a) a field for the class year they graduated; and
b) a field called "resume" (hyperlinked, like the "website" field) into which they could enter the url for their resume (which they will host locally in .pdf  format...).

Also generally, I'm sure these are fairly easy things to learn. If I want to start writing my own code to work behind the scenes in SMF, what language exactly would I need to learn, and do you recommend any good resources for it?

Long post. Thanks for any help you can give.  :)
Title: Re: Adding Fields to Profile template
Post by: Oldiesmann on September 13, 2004, 02:51:47 PM
To remove the fields:

In Themes/default/Profile.template.php:

Find
// All the messenger type contact info.
echo '
<tr>
<td width="40%"><b>', $txt[513], ': </b><br /><span class="smalltext">', $txt[600], '</span></td>
<td><input type="text" name="ICQ" size="24" value="', $context['member']['icq']['name'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[603], ': </b><br /><span class="smalltext">', $txt[601], '</span></td>
<td><input type="text" name="AIM" maxlength="16" size="24" value="', $context['member']['aim']['name'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt['MSN'], ': </b><br /><span class="smalltext">', $txt['smf237'], '.</span></td>
<td><input type="text" name="MSN" size="24" value="', $context['member']['msn']['name'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt[604], ': </b><br /><span class="smalltext">', $txt[602], '</span></td>
<td><input type="text" name="YIM" maxlength="32" size="24" value="', $context['member']['yim']['name'], '" /></td>
</tr><tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr>';


And delete it.

As far as adding fields - check out http://unknown.network32.net/tutorial.smf_custom-profile
Title: Re: Adding Fields to Profile template
Post by: [Unknown] on September 13, 2004, 11:54:40 PM
PHP would be the most helpful....

http://www.simplemachines.org/community/index.php?board=41.0

-[Unknown]
Title: Re: Adding Fields to Profile template
Post by: zknower on September 14, 2004, 12:04:13 AM
thanks to you both. i got the entry fields removed, and have succesfully added one simple text field.

in adding additional ones however, i seem to have misplaced an apostrophe, or something. now i am going over all my code with a fine-toothed comb trying to figured out where i went wrong in a language i only half-understand....although just from this exercise i've figured out a lot that i didn't know earlier today  :)

i'll try to take a look at the PHP lessons later this week......

thanks again!
Title: Re: Adding Fields to Profile template
Post by: Metho on September 14, 2004, 12:06:38 AM
If you post the section you added (as well as some of the code surrounding that code, someone here might be able to see the problem. Or you can work it out on your own.

- Methonis
Title: Re: Adding Fields to Profile template
Post by: zknower on September 14, 2004, 12:11:41 AM
is there an easy way to identify line numbers? i'm getting a message that the error is in line 178, but neither TextEdit nor MS Word seems to have an easy way of counting these......
Title: Re: Adding Fields to Profile template
Post by: 3fifty on September 14, 2004, 12:20:51 AM
Im sorry to hijack the thread.  I read the tutorial and it helped out a ton.  I have one problem though.  I now have two "Locations" in the profile.  One shows up in posts and one doesnt.  What do I need to do to clear this up?  The one marked "Fill This In" is the one that shows up in posts.  The other doesnt.

Thanks.

(http://www.nctuners.com/forum/index.php?action=dlattach;topic=3376.0;id=2606;image)
Title: Re: Adding Fields to Profile template
Post by: zknower on September 14, 2004, 12:34:29 AM
Hey, I'm (clearly) no expert, but I just read the tutorial too, and almost had the same problem.

The issue is that the tutorial uses, as an example field, a field that is already part of SMF (ie, "Location").

When you put your new code in, you need to besure you change the word "location" wherever it appears in the code you copy. This includes terms such as "text_location". So change it to the name of the actual new field you want. For example, I did this with a new field called "Class Year".

So I took the tutorial's code:
</tr><tr>
        <td width="40%"><b>Location: </b></td>
        <td><input type="text" name="default_options[text_location]" size="50" value="', isset($context['member']['options']['text_location']) ? $context['member']['options']['text_location'] : '', '" /></td>

and changed it to:
</tr><tr>
        <td width="40%"><b>Class Year: </b></td>
        <td><input type="text" name="default_options[text_class]" size="50" value="', isset($context['member']['options']['text_class']) ? $context['member']['options']['text_class'] : '', '" /></td>

Note that in the first line of the code, I used "Class Year", because that's what is displayed to the user; but in the second and third lines, I only used "class", because I needed a short, one-word string to act as a variable.

hope this clears it up....
Title: Re: Adding Fields to Profile template
Post by: zknower on September 14, 2004, 12:38:57 AM
MEANWHILE,

I found my misplaced (or missing) apostrophe..... all now seems to be working, except somehow, my email moved to the top of the column and to the left.

go figure ::sigh::

I'll try again tomorrow!  :)

zsk
Title: Re: Adding Fields to Profile template
Post by: 3fifty on September 14, 2004, 01:07:20 AM
Again sorry to hijack, I understand what you did with changing the words.  However I want the Location to show up in the posts and not just in the profile.  So I want to remove the default one.  Thanks for explaining it soo thoroughly, I appreciate that.
Title: Re: Adding Fields to Profile template
Post by: [Unknown] on September 14, 2004, 02:04:04 AM
Quote from: zknower on September 14, 2004, 12:11:41 AM
is there an easy way to identify line numbers? i'm getting a message that the error is in line 178, but neither TextEdit nor MS Word seems to have an easy way of counting these......

http://www.context.cx/

3fifty, what you want to do is probably just show the built in one, right?  Why not just use, intead of $message['member']['options']['text_location']... $message['member']['location'] ;)?

You know, I can't believe it.  I just picked something when writing that tutorial - I'm such a dope I actually never realized I picked one that was already in the profile :-[.

-[Unknown]
Title: Re: Adding Fields to Profile template
Post by: zknower on September 14, 2004, 09:39:32 AM
Unknown, i found the tutorial VERY helpful and clear. you'd better not be flogging yourself for such a minor oversight.  :)

i went to look at ConTEXT, and of course, it's windows only (as far as i can tell).

any recommendations for us lowly Mac users?

thx,
zsk
Title: Re: Adding Fields to Profile template
Post by: [Unknown] on September 14, 2004, 07:57:02 PM
Quote from: zknower on September 14, 2004, 09:39:32 AM
Unknown, i found the tutorial VERY helpful and clear. you'd better not be flogging yourself for such a minor oversight.  :)

i went to look at ConTEXT, and of course, it's windows only (as far as i can tell).

any recommendations for us lowly Mac users?

BBEdit.  I think it's not free, but when I was using a mac... it was by far the best.

Been a few years now, not sure if it is anymore.

-[Unknown]
Title: Re: Adding Fields to Profile template
Post by: Oldiesmann on September 15, 2004, 02:14:02 PM
I've heard that BBEdit is good. I don't have a mac though :)
Title: Re: Adding Fields to Profile template
Post by: zknower on September 16, 2004, 01:23:37 PM
I've started using BBedit. It rocks! Thanks for the suggestion!  :)