News:

Wondering if this will always be free?  See why free is better.

Main Menu

Adding addtional Items to Profile

Started by Alisha, July 06, 2004, 04:35:25 PM

Previous topic - Next topic

Alisha

I know this was already posted, although it was some time ago, and I am unable to find the old topic, so I started a newer one.

I wanted to add another item to the profiles on my forum. I went though and followed [unknowns] quick reference on how to do this, and poof it was there! Thanks Unknown! :)

Although, I want to make some changes that he didn't cover in his reference. Currently I have added a line for Blog/Journal: and it has a text box to enter the URL. This now displays Blog/Journal: http://XXXXX

Well I would like it turn into a button that will open the link entered into the text box in a new window when clicked from the profile!  Similar to the Website Text link, although a button instead of a text link.

Here is my code now:
</tr><tr> <td width="40%"><b>Blog/Journal: </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:

</tr><tr> <td><b>Blog/Journal: </b></td> <td>', isset($context['member']['options']['text_location']) ? $context['member']['options']['text_location'] : '', '</td>


I would like my result to be Blog/Journal:  [button] that links to the site entered in the profile in a blank (new) window!

I have tried several things, but none seem to work right.

Thanks!


[Unknown]

</tr><tr>
   <td><b>Blog/Journal: </b></td>
   <td>', isset($context['member']['options']['text_location']) ? '<a href="' . $context['member']['options']['text_location'] . '">BUTTON!!</a>' : '', '</td>


-[Unknown]

Vinoth

what file i have to edit for this addition into my forum/
Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

Alisha

Quote from: WebHoststalk on July 07, 2004, 06:34:16 AM
what file i have to edit for this addition into my forum/


You want to edit the yourtheme/Profile.template.php. Complete details can be found here;

http://unknown.network32.net/tutorial.smf_custom-profile

----

Thanks [unknown]

Vinoth

Vinoth And Sachin ( SpecHackers Team )
The Best  Way to Help Poor Is not Becoming One Of Them.

mafro

I may be being stupid but doesnt [Unknown]'s tutorial just show you how to put a field on the page??  How does the database update work?

Ive managed to do all the stuff in the tutorial on my own - I need some useful info about SMF does its database ops!  For example:  where the hell is the SELECT sql done for the profiles page?

It may be coz im working with my own DB tables that my stuff doesnt fit - thats why i need to find the SQL!
Thanks for a great board and any help

Mafro

Grudge

The additional profile stuff is clever - it DOESN'T need any SQL stuff. You just put the field on the page and SMF automatically handles the database backend. FYI all "additional" fields are stored in the themes table...
I'm only a half geek really...

mafro

Cool yeh - i pretty much worked out SMF must do something clever with the SQL to hide it from theme developers..

Like someone said on a previous thread it seems a bit stupid to store extra fields in the themes table - although these decisions arent for us mere minions to question!  :P

In my case i need to put the data from my extra profile field in a new table.  Where would it be sensible to put my update SQL?  Id just slap it in the update functions in Profile.php - but given the odd way in which we add extra profile items currently im hoping someone can tell me the best way to go about my problem...

Ive also got to populate the fields - any ideas where thats sensible to put?

Sorry to ask so many questions - i only started on SMF today and i prob wont decide the best solution to this prob until ive been developing for it for a month!! >:(

Mafro

Grudge

If you don't want to do it the current way I'd personally add a new field to the members table for it. Then modify Profile.template.php to add the input box for it, and then add the variable to ModifyProfile2 (I think it's called that) in Profile.php. If you find that function you'll see it's not too much to change...
I'm only a half geek really...

[Unknown]

I'll say this once more:

Themes is a blanket table, as in "theme stuff" - theme settings, theme options, etc.  It's faster this way, and it really doesn't change anything, does it?

-[Unknown]

mafro

Ill say this once more:

Its stupid to put member specific information in a "Themes" table.

Fair enough I see your point, but in my case im creating a table of members vs email addresses - on my board i need a list of emails for each person.

Hence, where should i update my new table?  In ModifyProfile2()?

It doesnt affect you doing it this way, so will you share the knowledge on how profile update actually works?

Grudge

I'm not hiding anything from you... it's open code for anyone to look at ;)

Anyway  - I was wrong about ModifyProfile2, it's actually in saveProfileChanges.

Just look about 20 lines into the function where all the arrays are - just add your new "column" to the relevant array (string, int etc).

I think that takes care of the storing of the variable. Obviously you'll need to edit Load.php too to ensure the setting is loaded, in function loadMemberData I believe.

The reason why data is stored in the themes table is purely as it makes it easy for people to add fields. To add it like you want (members table) means modifying the code. The themes table method allows people with only very limited php knowledge to add new fields.
I'm only a half geek really...

Riot

I know this is a pretty dead thread, but I was wondering if someone could update the link to the tutorial, also has anyone been able to add photo's (not an avatar) to the profile page? 

Thanks in advance.

geg

This is quite intressting. is it possible to searcht the custom fields ? How ? Maybe some could please point me in the right direction ?

Thanks

feeble

#14
i dont know if its any help to anyone, but it has help me greatly with what im trying to get done.

ive made a small ssi script, that returns all members from a particular group. and also gets the custom fields(from the theme table) and displays all the data in a table.(as all the data is stored in an array.

if anyone is interested i can send you the code(or post it here, not to sure if im allowed to as atm it contains msn details of my clan members)
as it may take a bit of tweaking to get the data your after. but it works.

feeble

#15
Test Code to show how to combine unknown's Custom Profilefield with users profile

If you need help with what you need this for, please feel free to ask.

Since the data in the Custom Profilefield is stored in the theme table, we need to combine the data into one array for use. This is just one possible solution

Quick Demo: two custom profiles (xfire and bf2pid) linked upto the correct profile.
http://www.nsxhq.com/index.php?page=37

Note: So that only users from membergroup 11 in the table
if(preg_match('/11/i', $row['additionalGroups']))

if you need anyhelp at all with incorporating this into your site please feel free to ask.
Code:

global $db_prefix, $scripturl;

$request = db_query("
SELECT ID_MEMBER, realName, posts, additionalGroups
FROM ".$db_prefix."members", __FILE__, __LINE__);
$return = array();
$counter = 0;
$ifxfire = "";
$ifbf2pid = "";
while ($row = mysql_fetch_assoc($request))
{
if(preg_match('/11/i', $row['additionalGroups']))
{
$request_member = db_query("
SELECT ID_MEMBER, variable, value
FROM {$db_prefix}themes
WHERE  ID_MEMBER='".$row['ID_MEMBER']."'", __FILE__, __LINE__);
while ($row_member = mysql_fetch_assoc($request_member))
{
if($row_member['variable'] == "Xfire")
$ifxfire = $row_member['value'];
if($row_member['variable'] == "bf2pid")
$ifbf2pid = $row_member['value'];
}
$return[$counter] = array(
'id' => $row['ID_MEMBER'],
'name' => $row['realName'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'bf2pid' => $ifbf2pid,
'xfire' => $ifxfire);
$ifxfire = "";
$ifbf2pid = "";
$counter++;
}
}

mysql_free_result($request);

$temp_array = array();
foreach ($return as $member)
{
$temp_array[] = "<tr><td>".$member['link']."</td><td>".$member['xfire']."</td><td>".$member['bf2pid']."</td></tr>";
}

echo "<table  width='95%' align='center'><thead><tr>
<th >Name (".$counter.")</th>
<th >Xfire</th>
<th >BF2 Pid</th>
</tr></thead><tbody>";
echo implode('', $temp_array);
echo "</tbody></table>";


Example Use: BF2 Leaderboard
http://www.nsxhq.com/index.php?page=33


Updated Post: Bit more clearer now, as i was in a rush when i wrote it before

Advertisement: