Info from the database Help/Info

Started by a454nova, May 08, 2012, 03:23:14 PM

Previous topic - Next topic

a454nova

I'm looking to pull info from the database like the way $member_info['posts'] dose from the "posts" under Forums_members. I use download pro and I want to show the users credits.

Question is, unless there is a better way, where is the code at where ['post'] pulls the value from the database.  I want to just copy it and edit it to pull the value from DL Credits.

Anyone know?  Thanks!

a454nova

Bump,   Anyone know where this is?   

Arantor

I'm not sure what you're trying to do. I don't recall $member_info anywhere in SMF and if you're referring solely to the Download Pro mod, you probably should ask its author on smfhacks.com.

a454nova

Ok well I may be pulling that from a mod. I'm not referring to the download Pro mod.  I'll explain it different.

Under your profile (Even here) it shows...

Username:                      a454nova
Posts:                             53 (0.033 per day)
Gender:                           Male
Age:                                28
Location:                         Aurora, CO

I want to add a line under Posts:


Username:                      a454nova
Posts:                             53 (0.033 per day)
Credits:                           50                         <------------------------------  ADD THIS
Gender:                           Male
Age:                                28
Location:                         Aurora, CO

In the database under "Fourm_Members" its called "downpro_credits" 

How do I add this line?  On a second note, I would just like to know how the site pulls that info from the database.

Thanks for the help guys!!   :)

Arantor

This is where it gets very complicated, because it's done in four separate places.

loadMemberData in Load.php loads the data from the database
loadMemberContext in the same file then converts it to a different format internally
prepareDisplayContext in Display.php then grabs that data and gets it ready for display
template_main in Display.template.php then actually displays it

That's how it does it, I can go through and pull the relevant edits but I don't have a copy of 2.0 to hand to look at... :/

a454nova

Quote from: Arantor on May 11, 2012, 06:58:06 PM
This is where it gets very complicated, because it's done in four separate places.

loadMemberData in Load.php loads the data from the database
loadMemberContext in the same file then converts it to a different format internally
prepareDisplayContext in Display.php then grabs that data and gets it ready for display
template_main in Display.template.php then actually displays it

That's how it does it, I can go through and pull the relevant edits but I don't have a copy of 2.0 to hand to look at... :/

I swear I've been through Load.php, but I guess I was looking for the wrong thing...  Damn late nights!!

Arantor!!!!  You sir are an Awesome Bad Azz!!!    Thanks!!!!


For anyone that would like to do the same thing-

Load.php  Line 493 ish              'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'],
                   Add below it ->       'downpro_credits' => empty($user_settings['downpro_credits']) ? 0 : $user_settings['downpro_credits'],

Now ['downpro_credits'] has a value and you can use it anywhere.  This will work for any value you wanna pull from the Database.

Thanks again Arantor!


Arantor

$user_settings is the *current user*'s value, not the user whose profile it is. I presume that isn't what you want.

(In which case you have to modify the places I mentioned)

a454nova

Quote from: Arantor on May 11, 2012, 08:55:25 PM
$user_settings is the *current user*'s value, not the user whose profile it is. I presume that isn't what you want.

(In which case you have to modify the places I mentioned)

I only have it showing for the user them self. Not for everyone else to see. As the admin, I can see it in the Download Admin panel anyways.  This was for them to see their own and I'm using it in the Simple Portal Mod too.

Will that work?

Arantor

See, I thought you were going to put it, as you said, under the poster information in a thread and thus see everyone's. (Which is why I gave you the pointers to Display.php and Display.template.php, if you wanted to put it in the profile, that's a different set of code again)

What you have is mostly workable - except if an admin looks at a user's profile, they will see their own count rather than what the user has available, which can make answering questions difficult.

Advertisement: