PDA

View Full Version : Show Avatars on custom vB page? Do I need to query the db?


ludachris
06-23-2009, 06:04 PM
I built a custom vB page that has a query to get user data from the db. If I wanted to include avatars on that page, would I have to modify the query to include avatar data? This is for 3.8.

Here's the existing query:

$users=$db->query("SELECT *
FROM " . TABLE_PREFIX . "user AS user, " . TABLE_PREFIX . "userfield AS userfield
WHERE user.userid = userfield.userid
ORDER BY $orderby $direction
LIMIT $pos,$perpage");



I'm assuming once the query is ready, I'll just need to modify the template with an IF Conditional like:

<if condition="$show['avatar']"><img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" /><br></if>

Dismounted
06-24-2009, 06:47 AM
Take a look at what is done in the function: fetch_avatar_url().

ludachris
06-24-2009, 02:28 PM
Take a look at what is done in the function: fetch_avatar_url().
Which file would I find that in? function_user.php?

Dismounted
06-25-2009, 05:35 AM
Yep. A good idea is to also keep a mass search tool handy - this allows you to find things quickly. (Many editors have this feature.)

ludachris
06-25-2009, 03:43 PM
Yep. A good idea is to also keep a mass search tool handy - this allows you to find things quickly. (Many editors have this feature.)
I guess I could have done a mass search in Homesite or Dreamweaver.... sorry.

ludachris
07-12-2009, 10:19 PM
Just a follow up to this question...

I added a require statement to the custom vb file I have, pulling in function_user.php. Shouldn't I now be able to use the same variables in my templates that function_user.php uses so that I can pull in the avatar that way?

Dismounted
07-13-2009, 03:03 AM
functions_user.php does not run any code when you include it. It is merely a library of functions that allow you to fetch and manipulate data about the user. Alternatively, you could simply have a look at what fetch_avatar_url() does, and "merge" the query with your own; removing the use of functions_user.php altogether.