Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other
Author Message
dezblack
Hangin' Around



Joined: Nov 26, 2008
Posts: 38

PostPosted: Wed Nov 26, 2008 2:40 pm Reply with quote

How do I remove the "location" info and add different info (custom fields added with 2.30) in the Authors info when viewing threads?
 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Wed Nov 26, 2008 4:57 pm Reply with quote

Around line 400 of viewtopic.php you will need to edit to query your new fields.
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'];


Around line 1195 of viewtopic.php you will have to pass your new fields to the template.
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,


Then edit viewtopic_body.tpl to include your fields in the page layout.

Note: Do not remove any fields you do not want, just add new ones. That is of course other than in the template.

_________________
"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. 
View user's profile Send private message
dezblack







PostPosted: Wed Nov 26, 2008 5:30 pm Reply with quote

Thats what I needed! do you know how i can find out what I need to add for my custom fields? I could not find them by digging around in phpmyadmin..
 
dezblack







PostPosted: Wed Nov 26, 2008 9:16 pm Reply with quote

I found the data under _users_fields_values.
How can I pull just the information for the field I need for the posting user?
There are 4 different fields per user. Please forgive me, I'm a begginer =)
 
Palbin







PostPosted: Wed Nov 26, 2008 10:51 pm Reply with quote

Without looking I don't know the structure of the custom fields. But It is kind of hard to understand what you are asking. Maybe one of the guys that worked on the new YA will be able to answer this.
 
dezblack







PostPosted: Wed Nov 26, 2008 11:14 pm Reply with quote

What you are sating would make complete since of the Custom info was stored under the _user table. But alas, it is stored in its own _users_fields_values table. It appears it will take an advanced query to get the correct info queried to use for the postrow.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Thu Nov 27, 2008 8:43 am Reply with quote

Well, you need to know which 'fid' values are for the custom fields that you added. You can get those from _users_fields and then you already have the user_id for the user, so you can use that for 'uid' and now you should be able to fashion a query against _users_fields_values to get the values you want.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
dezblack







PostPosted: Sun Jan 25, 2009 2:48 am Reply with quote

vid uid fid value
1 123 1 Champion
2 123 2 55
3 123 3 Daggar, Rolfiki, Breeann
4 123 4 Master Weaponsmith
5 48 1 Lore Master
6 48 2 60
7 48 3 Kitt, Catrian, Snoflakes
8 48 4 Historian
9 47 1 Hunter
10 47 2 60
11 47 3 Mirielle, Manered, Laerien, Markori
12 47 4 All



ok, I want to show fids 1, 2, 3 and 4. So , what would i use to query these and get it inserted in the postrow?

Please forgive my lack of knowledge, i'm trying =)
 
dezblack







PostPosted: Sun Jan 25, 2009 3:34 am Reply with quote

well now that i found some info, please forgive me for what i requested =)
I can see the scope is huge!

I need to do some learning, but this seems to be a start:

$result = mysql_query("SELECT * FROM nuke_users_field_values
WHERE uid='48' AND fid='1'")
or die(mysql_error());

// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo $row['uid']." - ".$row['value'];
 
montego







PostPosted: Sun Jan 25, 2009 9:18 am Reply with quote

It does take some SQL and PHP language skills to do, yes. I would suggest getting yourself a MySQL book and a basic PHP book, as I am sure you will want to do more hacking of code (customization) in the future.

Enjoy the road of learning. I sure have. Wink We cannot necessarily take the time to write the code for you, but if you get stuck down the road, we'll try and help as you progress along this journey.
 
Palbin







PostPosted: Sun Jan 25, 2009 11:51 am Reply with quote

This sql statement that you are trying to edit isn't exactly the easiest one to be learning on with all the u., p., pt. stuff.
 
Palbin







PostPosted: Sun Jan 25, 2009 12:22 pm Reply with quote

Just to give you a few hints. If you where just writing sql statements in pure php you would use mysql_query and mysql_fetch_array, but since we are writing in php nuke you need to use $db->sql_query and $db->sql_fetchrow. They will probably both work, but that is what you want.

Code:


$result = mysql_query("SELECT * FROM nuke_users_field_values
WHERE uid='48' AND fid='1'")
or die(mysql_error());


You are going to just want to select all fields with a uid equal to the user in question. You do not want to use where fid='1'. You want to select them all with one statement and then read them with a while loop.
 
dezblack







PostPosted: Mon Jan 26, 2009 12:21 pm Reply with quote

Well, i'm trying to play with some code to figure out how to pull the results from each fid. I have to specify the fid in the query to get the correct value to display. I can't get it to display correctly in my table though any suggestions or any links to where I can read up on my problem?

heres my code:
Code:
$query = "SELECT NUKE_USERS.username, NUKE_USERS.user_id, NUKE_USERS_FIELD_VALUES.uid, NUKE_USERS_FIELD_VALUES.fid, NUKE_USERS_FIELD_VALUES.value ".

 "FROM NUKE_USERS
 LEFT JOIN NUKE_USERS_FIELD_VALUES ".
"ON NUKE_USERS.user_id = NUKE_USERS_FIELD_VALUES.uid
AND fid='1'
";


$result = mysql_query($query) or die(mysql_error());


 
echo "<center>"; 
   
  echo "<table border='1'>
    <tr>
      <th>Username</th>
     <th>Class</th>
     <th>Alts</th>
    </tr>";
while ($row = mysql_fetch_array($result)) {
      echo "<tr>";
      echo "<td>" . $row['username'] . "</td>";
     echo "<td>" . $row['value'] . "</td>";

}
$query2 = "SELECT NUKE_USERS.username, NUKE_USERS.user_id, NUKE_USERS_FIELD_VALUES.uid, NUKE_USERS_FIELD_VALUES.fid, NUKE_USERS_FIELD_VALUES.value ".
 "FROM NUKE_USERS
 LEFT JOIN NUKE_USERS_FIELD_VALUES ".
"ON NUKE_USERS.user_id = NUKE_USERS_FIELD_VALUES.uid
AND fid='3'
";
$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_array($result2)) {

     echo "<td>" . $row2['value'] . "</td>";
      echo "</tr>";
     echo "</table>";    
    }
 


and heres the result:
Only registered users can see links on this board! Get registered or login!

As you can see, I can get the correct info, but it will not show in the table correctly =(
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Other

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©