News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Adding a new section in profile and view it in members list

Started by ShadowDragon, October 15, 2006, 08:52:33 AM

Previous topic - Next topic

ShadowDragon

Hi everyone,

I'm running a SMF forum ;D on the website of my tennisclub. I would like to make the following adjustments:
1. Adding a field for a telephone number in the profile and view it in the profile summery.
2. Viewing that telephone number in the member list

I was able to complete 1. with this toppic: http://www.simplemachines.org/community/index.php?topic=72372.0
(I have used $context['member']['options']['profile_tel'])
But for 2.: I can't manage to let it view in the members list.

Is there anyone who knows how to make such an adjustment? I would really appreciated it.

Thanks in advance.

P.S. I have some knowledge of PHP

sawz

keep smiling, they'll always wonder what your up too.....

ShadowDragon

#2
You can only use the "custom profile mod" for editing the profile, but it doesn't include a function for the member list. I think the adjustment in the member list requires code adjustments. Is there anyone who knows where I can change the arrays $context['columns'] and $column?
All help is still welcome.
Greetings.

ShadowDragon

#3
After some 2 and a half hours of searching (total time spent is now on 5 and a half hours) I finally did it! :D

For everyone who is curious on how you do this and for helping persons who want to do something similar:

The next lines are a small walk-through for everyone who wants to:


  • Data in the member-SQL-table
  • add a new field to profile
  • viewing new headers in the memberlist

I wanted to add a field for entering telephone numbers in my profile and then view it in the memberlist. This is how it works:

Note:

  • if there is something like "mem.tel, " do don't type the ""  ;D
  • if there is search for you need to look for the text between "" in the document that I'm discussing

1. Data in the member-SQL-table
To get started you need to make a new field in your member-SQL-table. So I have added a the field "tel" of type "varchar(15)" after "emailAddress".

Then you want to edit the Sources/Load.php file.
Search for "if ($set == 'normal'){$select_columns = " In that list I have added "meme.tel, " after "meme.emailAddress, "

Then search for "elseif ($set == 'profile'){$select_columns = "
Also in that list I have added "meme.tel, " after "meme.emailAddress, "

Then search for "$memberContext[$user] = array("
I have added "'tel' => &$profile['tel']," under "'email' => &$profile['emailAddress'],"
Now you can use the data that is stored in the field "tel" in the member-SQL-table.

2. Add a new field to profile
For this one we are going to modify Sources/Profile.php and Themes/default/Profile.template.php

First Sources/Profile.php (All the modifications we make here is that the data for the SQL-database would be useable in Themes/default/Profile.template.php)
Search for "$profile_strings = array(" and add " 'tel',"
Search for "$context['member'] += array(      'birth_date'" and add "      'tel' => !isset($user_profile[$memID]['tel']) ? '' : $user_profile[$memID]['tel'],"
Search for "// Overwrite member settings with the ones you selected." and add "      'tel' => !isset($_POST['tel']) ? '' : stripslashes($_POST['tel']),"

Then edit Themes/default/Profile.template.php
In "function template_summary()" you add "<tr><td><b>Tel. :</b></td><td>', $context['member']['tel'], '</td></tr>" on the place where you want to view your telephone number in the profile summary.
In "function template_forumprofile()" you add "<tr><td width="40%"><b>Tel. :</b></td><td><input type="text" name="tel" size="15" value="', @$context['member']['tel'], '" /></td></tr>"on the place where you want to let the user input his telephone number on the page where you can edit your profile.

Now you can input your telephone number, it will be saved in the database and viewed on the summary page.

3. viewing new headers in the memberlist
For this one we are going to modify Sources/Memberlist.php and Themes/default/Memberlist.template.php

In Memberlist.php we make the following adjustments:
Search for "// Set up the columns..." and add "'tel' => array('label' => 'tel','width' => '25'),"
Search for "// List out the different sorting methods..." and add "'tel' => array('down' => 'LENGTH(meme.tel) > 0 DESC, ISNULL(meme.tel) OR meme.tel [nofollow] = 0 ASC, meme.tel [nofollow] ASC','up' => 'LENGTH(meme.tel) > 0 ASC, ISNULL(meme.tel) OR meme.tel [nofollow] = 0 DESC, meme.tel [nofollow] DESC'),"

In Themes/default/Memberlist.template.php
Search for "// Assuming there are members loop through each one displaying their data." and add "<td class="windowbg2">', $member['tel'], '</td>" on the place where you want to view your telephone number
Then change in the whole document everywhere there is "colspan="12"" into "colspan="13"" because we just added a new column.

That's it. If you understand the code you are pasting in your documents you understand how easy to adapt and how good this Simple Machine Forum-software really is.

Edit on 30 May 2007 & 7 October 2007 :

  • Database name change

    • Version 1.1 & 1.1.1: should work fine
    • Version 1.1.2 & 1.1.3 & 1.1.4: change "meme" to "mem"
  • Function name change

    • Version 1.1 & 1.1.1: should work fine
    • Version 1.1.2 & 1.1.3 & 1.1.4: search on "function template_forumProfile()" instead of "function template_forumprofile()"

champwarez

well done. So, how can we add it to managemembers.template.php ? I don't want to people see everybody's telephone number.

Advertisement: