UBB.Dev
Posted By: Iann128 Displaying a gif for a paying member - 12/29/2008 7:44 PM
I started a thread over at ubb but it looks like it is more of a mod than is supported over there. I have tried to edit post_side.tpl with

Code
 <br />
{if (in_array("10",$groups))}
<img src="{$config.BASE_URL}/images/member.gif" alt="Member" />
{/if}

and added a query to showflat.inc.php like this that I took from user.inc.php I also added "groups" => $groups, to the Smarty part of the code...
Code

// First we grab all of their groups
$query = "
select GROUP_ID
from {$config['TABLE_PREFIX']}USER_GROUPS
where USER_ID = ?
";
$sth = $dbh->do_placeholder_query($query,array($Uid),__LINE__,__FILE__);

$groups = array();
while($result = $dbh->fetch_array($sth)) {
$groups[] = $result['GROUP_ID'];
} // end while

$_SESSION['mygroups'] = serialize($groups);

Any ideas as to why the gif does not show up frown

Thanks,
Ian
Posted By: Ruben Rocha Re: Displaying a gif for a paying member - 12/29/2008 9:35 PM
I assume by not showing up you mean the old red X?
The image should be in images/general/default and images/general/defaultdark. Same place as adm.gif is located
Posted By: Iann128 Re: Displaying a gif for a paying member - 12/30/2008 2:54 AM
No red x, just no picture... If I view source on the page the code to display it is not there...

Ian
Posted By: blaaskaak Re: Displaying a gif for a paying member - 12/31/2008 1:37 PM
I would do a slightly different approach that doesn't involve a template edit:

First of all, we don't want to know every group the user is in, we just want to know if they are in (your case) group 10.

Second, running this query for every user can be time consuming. This adds a query per post, you can find out every user in a topic that is in group X by using this query:

SQL Query

select distinct(t1.USER_ID)
from ubbt_USER_GROUPS as t1,
ubbt_POSTS as t2
where
t1.USER_ID = t2.USER_ID
and t1.GROUP_ID = 7
and t2.TOPIC_ID = 18499

Using this query, you could build an array with every user from topic 18499 that is in group 7.

In /scripts/showflat.inc.php you could check out that array to adjust the Membertitle string to add a graphic.

find:
PHP Code

if ($CustomTitle && $config['ONLY_CUSTOM']) {
$postrow[$i]['Title'] = $CustomTitle;
$CustomTitle = "";
} else {
$postrow[$i]['Title'] = $Title;
$postrow[$i]['CustomTitle'] = $CustomTitle;
}


There the title is put in a string.

If you put some code just below there to add a string to the customtitle string with a graphic, you don't need to adjust the templates, and it will work for both post_side and post_top templates.

I can be more complete about this next year if you need more help, I know it sounds ages, but it's actually tomorrow laugh
Posted By: Iann128 Re: Displaying a gif for a paying member - 12/31/2008 5:35 PM
Thanks for the help! I assume the query would go into showflat.inc.php somewhere? I have been messing around with the main query in showflat.inc.php, but now I get as many posts as they are in groups frown and only 1 shows the image..

Ian

PS Happy New Year!!!!
Posted By: blaaskaak Re: Displaying a gif for a paying member - 01/01/2009 10:20 PM
okay, I edited /scripts/showflat.inc.php a bit:

Find:
PHP Code

$topic_info
= $dbh->fetch_array($sth, MYSQL_ASSOC);


add below:
PHP Code

// get array of graphic users

$query = "
select distinct(t1.USER_ID)
from
{$config['TABLE_PREFIX']}USER_GROUPS as t1,
{$config['TABLE_PREFIX']}POSTS as t2
where t1.USER_ID = t2.USER_ID
and t1.GROUP_ID = 6
and t2.TOPIC_ID = ?
"
;
$sth = $dbh -> do_placeholder_query($query,array($topic_info['TOPIC_ID']),__LINE__,__FILE__);
$graphicusers = array();
while (list(
$graphicuserid) = $dbh -> fetch_array($sth)) {
$graphicusers[] = $graphicuserid;
}


Group 6 is hardcoded, and of course you need to adjust the text graphic to html to the actual graphic.

Hope this helps.

Find:
PHP Code

if ($CustomTitle && $config['ONLY_CUSTOM']) {
$postrow[$i]['Title'] = $CustomTitle;
$CustomTitle = "";
} else {
$postrow[$i]['Title'] = $Title;
$postrow[$i]['CustomTitle'] = $CustomTitle;
}


Add below:

PHP Code

if (in_array($usernum,$graphicusers)) {
$postrow[$i]['CustomTitle'] .= "<br />Graphic!";
}

Posted By: Iann128 Re: Displaying a gif for a paying member - 01/01/2009 10:53 PM
That is exactly what we needed! Thanks!!!!!

Ian
Posted By: Iann128 Re: Displaying a gif for a paying member - 01/02/2009 6:31 AM
Just a quick question Yarp, the moderators are asking if it can be moved down below the avatars or the location field is there a way to do that?

Thanks,
Ian
Posted By: blaaskaak Re: Displaying a gif for a paying member - 01/02/2009 12:29 PM
Yes there is.

Easiest would be the location field, to avoid template edits.

The code that actually changes the custom title now to custom title+graphic should be changed to change the location field.

PHP Code

$postrow
[$i]['Location'] .= "<br />Graphic!";


edit: Below the avatar is simple too, just change the Registered: string

PHP Code

$postrow
[$i]['Registered'] = "Graphic!<br />".$postrow[$i]['Registered'];

Posted By: Iann128 Re: Displaying a gif for a paying member - 01/02/2009 7:08 PM
Thanks again, I kinda figured that was what you were doing with the .= bit. I will give it a shot.

Ian
Posted By: blaaskaak Re: Displaying a gif for a paying member - 01/02/2009 10:11 PM
yeah.

PHP Code

$string
= "hello ";
$string .= "world";
echo
$string;


will result in
Code

hello world
Posted By: Iann128 Re: Displaying a gif for a paying member - 01/06/2009 4:13 AM
Cool one more quick one (I hope) where would I include this in showprofile.inc.php so the member image would show up. I had one of the mods ask because she posts birthdays and events for dues paying members..

Thanks again,
Ian
Posted By: blaaskaak Re: Displaying a gif for a paying member - 01/06/2009 8:20 AM
It all depends on which spot you want it displayed.
Posted By: Iann128 Re: Displaying a gif for a paying member - 01/06/2009 3:04 PM
Just about anywhere would be good, over by the avatar would be cool.

Thanks,
Ian
Posted By: AllenAyres Re: Displaying a gif for a paying member - 01/15/2009 5:05 PM
Would a simpler approach be to just include a graphic in the custom title for a paid usergroup? I don't remember if that field allowed html, I think I remember Ian adding a marquee to that spot in earlier versions smile
Posted By: blaaskaak Re: Displaying a gif for a paying member - 01/15/2009 6:39 PM
Very simple approach, it's just that users are allowed to edit their custom title, and you kind of go wrong there.
Posted By: AllenAyres Re: Displaying a gif for a paying member - 01/16/2009 6:17 PM
ah, thank you, it's been a while since I looked at it smile
Posted By: Ohton Re: Displaying a gif for a paying member - 01/16/2009 11:32 PM
Thanks for sharing,

If I have different levels of paying groups, how can I show an Icon for each?
Posted By: AKD96 Re: Displaying a gif for a paying member - 01/20/2009 8:29 AM
Originally Posted by blaaskaak
Very simple approach, it's just that users are allowed to edit their custom title, and you kind of go wrong there.
Couldn't you just edit the template for editbasic to simply not display the custom title field?
Posted By: Iann128 Re: Displaying a gif for a paying member - 02/16/2009 6:33 AM
Ok one more question... We have added subscriptions so there are more groups that should have the members gif, can I just add them to the same query? Can I use a "or" and in 10 or 11 or 12?

Thanks,
Ian
Posted By: blaaskaak Re: Displaying a gif for a paying member - 02/17/2009 7:20 PM
changelog for 7.5:

FEATURE It is now possible to add an image for each group. Users belonging to that group will be able to display that image next to their name. If a user belongs to multiple groups, the user can select a single or multiple images to be displayed.

It's just hit the beta cycle, so won't be long before it will be released.

As far as the query goes:

SQL Query

and t1.GROUP_ID = 6

should be replaced with

SQL Query

and (t1.GROUP_ID = 6 or t1.GROUP_ID = 7)

So you replace the original requirement with a bunch of them with or inbetween. But you group them together, because together they are one of the conditions).
Posted By: Iann128 Re: Displaying a gif for a paying member - 02/18/2009 2:57 AM
Thanks again, you are the Man! Yeah I saw the change log, can't wait to test it out. How does one get in the Beta group?
Posted By: sirdude Re: Displaying a gif for a paying member - 02/20/2009 12:25 AM
easier way to do a test for multiple groups would be

SQL Query
 AND t1.GROUP_ID IN (6,7)

you can keep adding commas and numbers at will smile

i like to minimize keystrokes laugh
Posted By: AKD96 Re: Displaying a gif for a paying member - 02/20/2009 1:23 AM
sirdude has lonely keys
Posted By: Iann128 Re: Displaying a gif for a paying member - 06/01/2010 5:26 PM
Hey guys I upgraded my testing site to 7.5 a little while ago and broke the mods I made, and the stock code displays the member image inline with the posts, not where I had it or want it. Will the mods still work if I go back and edit the files? I have not upgraded the main site for that reason.
Posted By: AllenAyres Re: Displaying a gif for a paying member - 06/03/2010 5:58 PM
It should, the code wasn't too difficult to follow from one version to the other for the most part, especially the templates.
Posted By: Iann128 Re: Displaying a gif for a paying member - 10/12/2010 5:23 PM
OK so now we have a different image for a "Recognized" member. I was going through the code, and trying to think how to do it without stacking them, I.E. one or the other. I assume I need to create a second array, then create logic to see which array they are in???
© UBB.Developers