Author |
Message |
dezblack
Hangin' Around
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Nov 26, 2008
Posts: 38
|
Posted:
Mon Mar 29, 2010 7:51 pm |
|
I have looked for documentation on how to display the custom fields for users on the forums. Under their posts, it now has username, avatar, rank, joined date and location. I would like some or all of my custom field values from RNYA to show as well. How do I do this? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Mon Mar 29, 2010 9:51 pm |
|
Do you have any PHP skills? If so I can give you a quick idea how to do it, but if not I don't have the time to do it for you. I know something like this has been talked about before, but I have no idea where you would find it in these forums. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 30, 2010 1:27 am |
|
Ok, I was wondering if there was something built in I was missing, guess not .
I do have a little php skill. I found the tables I'm looking for in nuke_users_field_values.
I found this in viewtopic.php:
Code:/ 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
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = '$topic_id'
$limit_posts_time
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time $post_time_order
LIMIT $start, ".$board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
}
$postrow = array();
if ($row = $db->sql_fetchrow($result))
{
|
and this too(seems to have some info already being shown):
Code:// Again this will be handled by the templating
// code at some point
//
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('postrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,
'POSTER_FROM' => $poster_from,
'POSTER_AVATAR' => $poster_avatar,
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'SIGNATURE' => $user_sig,
'EDITED_MESSAGE' => $l_edited_by,
|
Can I adjust the top code to include a query matching uid from the nuke_users_field_values to the u.user_id:
Code:/ Go ahead and pull all data for this topic
//
$sql = "SELECT c.*, 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
FROM " . WHATGOESHERE?? . " c, " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = '$topic_id'
$limit_posts_time
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
AND c.uid=u.user_id
ORDER BY p.post_time $post_time_order
LIMIT $start, ".$board_config['posts_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
}
$postrow = array();
if ($row = $db->sql_fetchrow($result))
|
and then set the array with something like:
And then put the code in the template for
I tried but it did not work, I'm assuming the WHATGOESHERE? I am using is incorrect..
I was using users_field_values
********EDIT**********
I used nuke_users_field_values and it worked.
My problem now is the array. I see each UID has 4 fid with 4 value tables.
How do I pull the info from the correct FID value to post to the array? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Mar 30, 2010 11:18 am |
|
am i on the right path or should I do something differently? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Apr 01, 2010 6:47 pm |
|
Yes, you are on the right path. I haven't had time to look into exactly how this would be done. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Apr 01, 2010 9:37 pm |
|
In /modules/Forums/viewtopic.php find lines 414-425:
Code:
$postrow = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$postrow[] = $row;
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
$total_posts = count($postrow);
}
|
Change to:
Code:
$postrow = array();
$userids= array();
if ($postrow = $db->sql_fetchrowset($result)) {
foreach($postrow as $key => $value) {
$sql = 'SELECT ufv.value as value, uf.name as name
FROM `' . $user_prefix . '_users_field_values` ufv, `' . $user_prefix . '_users_fields` uf
WHERE ufv.uid="' . $postrow[$key]['user_id'] . '"
AND uf.fid = ufv.fid';
$results = $db->sql_query($sql);
$row = $db->sql_fetchrowset($results, MYSQL_ASSOC);
foreach($row as $key2 => $value2) {
$postrow[$key]['custom_fields'][$row[$key2]['name']] = $row[$key2]['value'];
}
}
$db->sql_freeresult($result);
$total_posts = count($postrow);
}
|
Then around lines 1195 find:
Code:
$template->assign_block_vars('postrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
'POSTER_RANK' => $poster_rank,
'RANK_IMAGE' => $rank_image,
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,
'POSTER_FROM' => $poster_from,
'POSTER_AVATAR' => $poster_avatar,
'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'SIGNATURE' => $user_sig,
'EDITED_MESSAGE' => $l_edited_by,
|
After add the follwoing with "color" being the name of the custom field you want to use:
Code:
'COLOR' =>$postrow[$i]['custom_fields']['color'],
|
Then open /themes/YOUR_THEME/forums/viewtopic_body.tpl. If you theme does not have forum templates open /modules/Forums/templates/viewtopic_body.tpl. Again using "color" as an example all you need to do is add the following in the template to use the field vlaue:
For example if you wanted to display the users color under the their number of posts you would would find this around line 33:
Code:
{postrow.POSTER_POSTS}<br />
{postrow.POSTER_FROM}</span><br />
|
Change to:
Code:
{postrow.POSTER_POSTS}<br />
{postrow.COLOR}<br />
{postrow.POSTER_FROM}</span><br />
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Apr 03, 2010 6:07 pm |
|
thank you! this helps alot. I appreciate your time for posting this |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 2:59 pm |
|
I have decided to pull the needed info from a different table. I have it working great per adjusting your instructions with:
Code:
//Guild Rank//
$sql = "SELECT name, rank FROM lotroster WHERE name='$poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain Roster information', '', __LINE__, __FILE__, $sql);
}
$lotroster = array();
while ( $row = $db->sql_fetchrow($result) )
$lotroster_rank = $row['rank'];
$db->sql_freeresult($result);
|
I then send it to the template as you said. My problem is that I have members on the forum that are not in the database I am querying. So for instance, I have a user named Darana. She is not in it, so her result returned is the same as the person above her like this:
Darana
Kell member
Diogo officer
Darana officer
Timmy member
Darana member
Is there a way to make the returned value for her be "Guest", or even Blank? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 3:57 pm |
|
I can see how you would have the problem you are having. Where exactly are you putting this code you just posted?
I don't have time to look at this right now, but I will. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 4:47 pm |
|
starting at line 926
right above:
//
// Generate ranks, set them to empty string initially.
// |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 5:25 pm |
|
I need to know the field names in the "lotroster" table. Also do you still need to query the custom fields. I plan on leaving it, but just incase. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 8:52 pm |
|
no, those fields are now auto-propegated into the lotroster fields by another means. I run a Lotro kin website, lotroster is a script that pulls information for Turbine's database using a key, then displays the information.
Lotroster is a table in the same db as nuke_.
It has fields:
name (this one will always match exactly to nuke_users.username, unless one or the other or both are missing an entry, thats why I use name ='$poster')
char_id
Monster
Rank
Level
Class
Race
Vocation
Origin
Profession1
Proficiency1
Mastery1
Profession2
Proficiency2
Mastery2
Profession3
Proficiency3
Mastery3
PVMPRating
PVMPRank
PVMPPoints
Morale
Power
Armour
Might
Agility
Vitality
Will
Fate
Radiance
MeleeCrit
RangedCrit
TacticalCrit
FearResistance
WoundResistance
DiseaseResistance
PoisonResistance
CommonDef
FireDef
FrostDef
ShadowDef
LightningDef
AcidDef
Block
Evade
Parry
I do not need to pull all of them. I currently use this code to pull the ones I want(level, class, rank, vocation,radiance), but I know there's a better way to do it!
Code:
/////////////////////////////////////
// lotroster query //
/////////////////////////////////////
//Character info//
$sql = "SELECT level, class FROM lotroster WHERE name='$poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain Roster information', '', __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
$lotroster_info = $row['level']." " . $row['class'];
$db->sql_freeresult($result);
//Vocation//
$sql = "SELECT vocation FROM lotroster WHERE name='$poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain Roster information', '', __LINE__, __FILE__, $sql);
}
$lotroster = array();
while ( $row = $db->sql_fetchrow($result) )
$lotroster_vocation = $row['vocation'];
$db->sql_freeresult($result);
//Guild Rank//
$sql = "SELECT rank FROM lotroster WHERE name='$poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain Roster information', '', __LINE__, __FILE__, $sql);
}
$lotroster = array();
while ( $row = $db->sql_fetchrow($result) )
$lotroster_rank = $row['rank'];
$db->sql_freeresult($result);
//Radiance//
$sql = "SELECT radiance FROM lotroster WHERE name='$poster'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain Roster information', '', __LINE__, __FILE__, $sql);
}
$lotroster = array();
while ( $row = $db->sql_fetchrow($result) )
$lotroster_radiance = $row['radiance'];
$db->sql_freeresult($result);
/////////////////////////////////////
// END lotroster query //
/////////////////////////////////////
//then later on after $template-> I added:
'RADIANCE' => $lotroster_radiance,
'RANK' => $lotroster_rank,
'CHAR_INFO' => $lotroster_info,
'VOCATION' => $lotroster_vocation,
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 9:47 pm |
|
I didn't physically try this, but it should work.
In /modules/Forums/viewtopic.php find lines 414-425:
Code:
$postrow = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$postrow[] = $row;
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
$total_posts = count($postrow);
}
|
Change to:
Code:
$postrow = array();
if ($postrow = $db->sql_fetchrowset($result)) {
foreach($postrow as $key => $value) {
$sql = 'SELECT rank, level, class, vocation, radiance FROM lotroster WHERE name="' . $postrow[$key]['username'] . '"';
$results = $db->sql_query($sql);
$row = $db->sql_fetchrowset($results, MYSQL_ASSOC);
foreach($row as $key2 => $value2) {
$postrow[$key]['custom_fields'][$key2] = $value2;
}
}
$db->sql_freeresult($result);
$total_posts = count($postrow);
}
|
Then you would use it like so:
Code:
'RADIANCE' => $postrow[$key]['custom_fields']['radiance'],
'RANK' => $postrow[$key]['custom_fields']['rank'],
|
If this works you can remove the code you posted above. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 9:57 pm |
|
Warning: Invalid argument supplied for foreach() in ................\modules\Forums\viewtopic.php on line 420
Code:foreach($row as $key2 => $value2)
|
|
Last edited by dezblack on Mon Apr 12, 2010 11:38 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Apr 12, 2010 11:05 pm |
|
is this because one of the fields is returning empty due to darana not being in the table? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Apr 13, 2010 2:48 pm |
|
dezblack, yes try the following.
Code:
$postrow = array();
if ($postrow = $db->sql_fetchrowset($result)) {
foreach($postrow as $key => $value) {
$sql = 'SELECT rank, level, class, vocation, radiance FROM lotroster WHERE name="' . $postrow[$key]['username'] . '"';
if ($results = $db->sql_query($sql)) {
$row = $db->sql_fetchrowset($results, MYSQL_ASSOC);
foreach($row as $key2 => $value2) {
$postrow[$key]['custom_fields'][$key2] = $value2;
}
}
}
$db->sql_freeresult($result);
$total_posts = count($postrow);
}
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
dezblack
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue Apr 13, 2010 5:42 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|