TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 468
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 209
  • Total: 209

PHP article and SMF Member Info

Started by Eversio, July 26, 2009, 10:30:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eversio

I'm trying to access $context['member']['..'] in a TinyPortal PHP article. I want to be able to get $context['member']['options']['country'] (Country Flag mod) for each member in an array. How would I go about accessing member data from a list of members in a PHP article. I'm pretty sure $context won't work but I'm not sure what other SMF variable to use.

Thanks,
Cory

JPDeni

Different parts of the $context array are loaded into memory depending on the ... context. :) It's likely that the ['country'] array is not loaded in every time.

I would suggest creating a temporary block or article that will print out the values in the array. You can use the print_r function, something like:


global $context;
print_r($context);


It'll be hard to read, but you can look through it to see if your ['country'] variable is there. You might actually do better to look at the source code for the page rather than the page itself.

This doesn't solve your problem directly, but it does give you some information about the $context array.

Eversio

I did the print_r and Country was not there, how would I go about forcing it in, if possible? Also, I know context gets info on the page/user logged in (yourself), from what I saw in the jumble of arrays shown, so would I be able to use Context to get the country from my own array of users?

JPDeni

I don't know where it's loaded because I don't have the mod installed myself. If you have a text editor which allows you to search through files for text, I would search for 'country' and see you can see where it's loaded.

Quotewould I be able to use Context to get the country from my own array of users?

I don't know. Do you want the data for all users or just the one that's logged in? If you want it for all users, you'll likely have to load it in yourself, using a query. I don't know how the info is stored in the database, though, so I can't help you with designing the query.

Eversio

Quote from: JPDeni on July 26, 2009, 11:24:42 PM
Quotewould I be able to use Context to get the country from my own array of users?

I don't know. Do you want the data for all users or just the one that's logged in? If you want it for all users, you'll likely have to load it in yourself, using a query. I don't know how the info is stored in the database, though, so I can't help you with designing the query.

I looked through the install file and it makes no database changes. I'm gonna have to talk to my friend to see if i'm looking at the right mod since he installed it a while ago. There are only 2 country flag mods on the SMF site so I'm fairly sure its the right one.

Basically I already have a query to get the list of users that I want, now I just want to display the flag next to their name.

IchBin

You can look at the files of the mod installed in your package manager if you want to see which mod it is, or even look at its install instructions.

JPDeni

If the install makes no database changes, the data is likely being stored in the smf_themes file.

mc

Mods that require information to be stored in the database, don't necessarily have to modify the database to do so, as I've just discovered.

After what JPDeni just said, I finally figured out where the twitter mod stores the twitter usernames. It stores them in the ***_themes table (*** being whatever your db prefix is).
I'm guessing the ***_themes table, is used to store all the array contents of $context['member']['options']?

I always wondered how only a couple lines of code could store and retrieve additional information!

JPDeni

QuoteI'm guessing the ***_themes table, is used to store all the array contents of $context['member']['options']?

Yeah, probably.

There's a whole tutorial written by [Unknown] over at the SMF site about adding profile fields and having them stored in the themes table.

Eversio

I'll take a look at that, thanks for the help.

This website is proudly hosted on Crocweb Cloud Website Hosting.