![]() |
Problems with avatar if conditional
I'm currently working on overhauling the entire showgroups template, but it seems I've come across one small issue that I'd like to fix before releasing my first 'mod'. Apparently, I've added an if conditional for showing the avatar. As such, I want it so that if a user has an avatar, it'll be displayed. Otherwise, it won't. In my case, however, neither will appear.
If I take away the if conditional, the avatar does appear, but then an annoying 2px by 2px image file appears for those who don't have an avatar. Here's the code I'm using for the avatar bit: HTML Code:
<if condition="$show['avatar']"> |
Which template is this in? And it's on the showgroups.php page? Is $show['avatar'] defined in the showgroups.php page? Or have you added a plugin to define it - if so, where and what are the contents?
|
The piece of code is in the 'showgroups_usergroupbit' template. Beside editing the templates itself, I've not done anything else to it.
|
I don't understand how an avatar is even showing when you have no "src" in your <img> tag and when $userinfo is not even the variable being used in that template. :/ Who's avatar is showing? Do you have a link to this page?
|
1 Attachment(s)
Quote:
Code:
src='image.php?u=$user[userid]' And I'd rather keep the board's url private from these boards as of yet, as it's in a beta still. I could PM you it however, if you'd like. Edit: see attachment. |
You cannot use image.php?u=$user[userid]. That is only valid if the avatar is in the database, not filesystem (and it's not complete at that - you should have &dateline=xxx on the end of it).
Take a look at the $posts query in showthreads.php around line 989. Look at the way the customavatar gets included. You need to include that in part of the query in showgroups.php (which is going to be a bit difficult since there isn't a hook to use). Then look at class_postbit.php, the function preocess_registered_user() where the avatar gets processed and $show['avatar'] gets defined. That is the sort of thing you will need to put into your code somewhere. |
I took a look at both files and at the right location (which you mentioned). I'm not an expert at PHP but do understand most statements and whatnot. However, I did a search and came across this post.
If what Brad has said is true, where would I have to put the code? That is, the script. Cheers. :) Edit: Well I've added a plugin with the contents of the first code block that Brad posted (see link), and tried global_start. That didn't bring up errors, but it wasn't displayed either. Then I tried the showgroups_complete, showgroups_start and showgroups_usergroup, which gave me two errors (the page didn't stop loading though). |
Brad's script will not work for you without quite a few changes (if even then). It's for getting the avatar of the person viewing the page - you - which is different than getting it for someone else in a query.
|
So I'm pretty much better off leaving that 2px / 2px image for those who don't have an avatar, than to try getting this to work? I've been messing around and tried to include some query after looking at said PHP files more, but I couldn't.
|
What you have done is not going to work at all if you have your avatars in the filesystem instead of the database.
|
Alright, I looked at showgroups.php once more and tried to figure out what the vital parts of the query would be. I came up with this:
Code:
$showgroups = $db->query_read(" HTML Code:
if ($this->post['avatarid']) |
Yes, that is much closer. I haven't actually read the code line for line, but it looks more like what I am used to seeing when an avatar is included.
|
Seems I keep getting an SQL error, but I don't know where it's coming from. :(
This is the query_read (or something, I'm a novice with SQL; used this query part from showthread.php (changed $posts to $show['avatar'])): Code:
$show['avatar'] = $db->query_read(" |
A query is not just the query_read part. You then just get left with pointers and have to get that data out of there by doing something like a fetch_array. *Then* you end up with variables you can do something with (you can see that in the showthread.php page).
|
Okay, I see the part where it's being fetched (if I am right), which starts at:
PHP Code:
Also, after having this done, should I pretty much edit the showgroups.php page to include the defined $show['avatar'] from the class_postbit.php? And as a last thing: should the case be that I have to adjust the query accordingly, what would be the best way to know which table (or whatever it is?) should be selected/called/queried? |
If you already have a query in the showgroups page that then goes through a while loop like we are talking about, most likely, you just want to combine the two queries into one query and do everything at once. Is that what you are doing right now?
|
I'm not quite certain whether or not I understood it correctly. Is showgroups.php supposed to have a query related to that already (seeing how you have referred to 'two queries into one')?
And no, I haven't edited the showgroups.php itself yet. I wanted to be certain how I should go on about this before messing up everything. My idea (my last post) was to basically copy the $show['avatar'] bit and put it in showgroups.php as well, so it's defined (which I could then use as a variable in the showgroups template). The same goes for the query from class_postbit.php. Or am I understanding this completely wrong? |
I assumed from your first post that you were going to be showing the avatars for the users in the groups on the showgroups page. If so, there is already a query to grab the users in each group, so you would then want to add the extra stuff to select to that query, I would think.
|
All times are GMT. The time now is 11:54 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|