PDA

View Full Version : Is there a way..


Mellymonster
06-26-2009, 03:36 AM
Is there a way to have post bit icons like a marital status icon, show up in the description in side the forum area?

I'm not talking about post icons.

https://vborg.vbsupport.ru/external/2009/06/6.png

That, I want when someone starts a thread, for that icon to appear automatically in the forum area without them having to do anything, is this possible?

https://vborg.vbsupport.ru/external/2009/06/7.png

freewilley
06-26-2009, 08:28 AM
I never came across such a mod but you might find some if you do a search or ask some coder to do it for you.. I am sure there are quite a lot around here who can do it for you for a good price.

regards

Spank
06-26-2009, 09:09 AM
This should be achievable with custom profile fields.

Mellymonster
06-26-2009, 03:05 PM
Right thats my forum, not sure you are reading it correctly, I am wanting to make that profile field appear when someone posts a thread, so members know if the OP of the thread is married or not married. KWIM?

--------------- Added 1246032424 at 1246032424 ---------------

I am just wondering, maybe if I took the postbit code for that and post it in the forum display or something area, would that work?

Maybe I am thinking of the wrong template.

BlueNinjaGo
06-26-2009, 03:11 PM
This is a wild shot in the dark... but in the forumdisplay template, there is $vbphrase[thread] / $vbphrase[thread_starter]

Perhaps a conditional after that?

Mellymonster
06-26-2009, 03:28 PM
hmm that didn't work I added this

<if condition="$post[field17]"> <img src="$stylevar[imgdir_misc]/$post[field17].gif" alt="$post[field17]" /></if>

BlueNinjaGo
06-26-2009, 03:39 PM
i'm pretty sure $post[] will only work in postbit templates... (maybe showthread?)

I doubt it would work in forumdisplay

Mellymonster
06-26-2009, 03:45 PM
oh right lol, but showthread didn't work either.

mikey1991
06-26-2009, 03:56 PM
hmm that didn't work I added this

<if condition="$post[field17]"> <img src="$stylevar[imgdir_misc]/$post[field17].gif" alt="$post[field17]" /></if>

Try adding that to the postbit template. Shot in the dark.

BlueNinjaGo
06-26-2009, 04:00 PM
oh right lol, but showthread didn't work either.

sorry, I wasn't suggesting to add it to the showthread template... Just trying to say that $post[] probably won't work in the forumdisplay template.

Try adding that to the postbit template. Shot in the dark.

That would add it to the postbit, which I'm pretty sure she said was already done.

Spank
06-26-2009, 09:35 PM
Use $bbuserinfo rather that $post. $post only works in the postbit I think.

Mellymonster
06-26-2009, 09:39 PM
so like this

<if condition="$bbuserinfo[field17]"> <img src="$stylevar[imgdir_misc]/$bbuserinfo[field17].gif" alt="$bbuserinfo[field17]" /></if>

In the forumdisplay?

Its not working :(

Spank
06-27-2009, 12:52 AM
Try:
<if condition="$bbuserinfo['field17']"> <img src="$stylevar[imgdir_misc]/$bbuserinfo[field17].gif" alt="$bbuserinfo[field17]" /></if>

Mellymonster
06-27-2009, 04:19 AM
I tried it and it doesn't work either :(

Spank
06-27-2009, 09:27 AM
ok, where are you putting it, and what is happening?

DragonBlade
06-27-2009, 01:04 PM
Yes, there is a way. There's a bunch of ways. xP It just depends on which you want to use.

The EASIEST way would be to create a plugin that will fetch user info for each thread displayed by the forum. BE ADVISED, though, that this will create an additional query for each thread loaded with the forum display. XD Not somethin' you want, probably.

Next easiest would be to execute a custom query with a JOIN, something like SELECT thread.postuserid, userfield.field17 AS maritalstatus FROM thread, userfield WHERE thread.threadid IN (0,$ids) AND thread.postuserid=userfield.userid in the 'forumdisplay_query' hook. With the results assigned to an array $marital_status_array (as userid => maritalstatus), you could put <if condition="array_key_exists($thread[postuserid], $marital_status_array)">blahblahblah</if> in the threadbit template.


If you're willing to go through that kind of work, tell me, and I'll post some step-by-step instructions. :)

Mellymonster
06-28-2009, 01:44 AM
I'm willing to go through with it, but can you make the instructions in layman terms :P it takes me a while to get things, but I'm willing to get it going.

--------------- Added 1246157167 at 1246157167 ---------------

ok, where are you putting it, and what is happening?

I was putting it in Forumdisplay where it was first told for me to place it, and nothing happen at all, it didn't show nothing what so ever.

DragonBlade
06-28-2009, 07:30 PM
All right, now, Melly. I'll make this simple on ye, but I STILL want you to try to understand the inner workings behind it, m'kay? That way, if vBulletin changes things around, you might have an idea what to do.

First thing's first. We'll use ONLY plugins for this, and no template edits or file edits. That way, if something does go wrong, all you have to do it turn off the plugin, kay? Good.

We'll start by Creating a Product. Load up yer AdminCP, and scroll on down near the bottom. Expand Plugins & Products, and click on Product Manager. Scroll aaaallllllll the way to the bottom and click "Add/Import Product." For the Product ID, just enter "melmaritalthreads" or something. For the Title, put "Mel's Marital Status for Threads." For the version, we'll go with "0.01a". Description, "Some help that wonderful Sarteck using DragonBlade's account gave me!" Ignore the Product and Version Check URLs. Save it.

Yay, you have a Product! Now to make some Plugins for the Product.

Again, under Plugins & Products, click this time "Add New Plugin." For Product, select "Mel's Marital Status for Threads." (The only reason we added that Product, btw, was to organize the plugins. ;) ) For the Hook location, select "forumdisplay_query".

TECHIE NOTE: This is the "location" in the script where the plugin will execute. If you open up your "forumdisplay.php" file, find the line:($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false;That basically means that this hook will execute in that spot. This is important, because it means we can use the variables already in memory up to that point, and influence some variables that will come later. END TECHIE NOTE.

Now, for the title, enter "Marital Status Thread Query." Leave the execution order at default (5). Now for the important bit--the actual plugin code:
// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0,%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
{$marital_statis_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}

What this does is it uses the $ids already gathered by vBulletin for the forumdisplay query, and puts the marital status of the users (assuming that's your field17) into an array with the thread ID as the key.

Leave "Plugin is Active" at no--you'll activate it in a moment. Save the plugin.



All right! Next plugin will be used to display field17 next to each user's name (I'm assuming that's where you want it, right?).

"Add New Plugin" again, select the Mel's Marital Status for Threads. Hook location is now 'threadbit_display'. (Also in the forumdisplay.php, a little further down, if you wanna glance at the PHP file.) Title this one "Marital Status Thread Display," because that's what this one will be doing--displaying the marital status. :) Leave the execution order at default, again (5).

The code here is relatively simple--we're just going to append the Marital Status onto the end of the postusername value for the thread. :3
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']];


TECHIE NOTE: the " .= " operator basically "concatenates" two strings, meaning it glues one onto the end of the other. END TECHIE NOTE.

Again, leave this off for now, and save it.



Almost done! Now all we need to do is go to the Plugin manager, locate the two plugins we just made, and put checkmarks in the boxes to activate them both. :) Now go look at your forums, and see if everything went smoothly. If there's some errors, it's liekly a typo in my code somewhere. XP Just deactivate the plugins and tell me what the error is.

If it works out, come back and tell me, too. :3

--------------- Added 1246227765 at 1246227765 ---------------

Is there a way to have post bit icons like a marital status icon, show up in the description in side the forum area?

I'm not talking about post icons.

https://vborg.vbsupport.ru/external/2009/06/6.png

That, I want when someone starts a thread, for that icon to appear automatically in the forum area without them having to do anything, is this possible?

https://vborg.vbsupport.ru/external/2009/06/7.png

Ho ho ho, also, if you didn't want it next to the name, but rather in the first column, change the variable in that second plugin to$thread['openclose_editable']And if you wanted it to the LEFT of the username, try$thread['postusername'] = $marital_status_threadids[$thread['threadid']] . $thread['postusername'];

mikey12561
06-29-2009, 06:22 AM
Hey There just to introduce myself. I'm Mikey one of Mellies Techs for the site. I went ahead and did everything that you told her to do and we got an error.

here is actually a screenshot of that error. I deactivated the plugins for now.

Mellymonster
06-29-2009, 07:03 AM
I just wanted to verify that he is one of my techies...

DragonBlade
06-29-2009, 09:29 AM
Okays, seems I made a spelling error AND added in an un-needed comma. XP

I tested this out on my forum and it works.



PLUGIN #1:// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
{$marital_status_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}
NOTE: The "," in the "WHERE thread.threadid IN" statement is now omitted.
NOTE2: I spelled "status" as "statis" in one variable. XD Oopsie.

See how that works out for ya.

chris1979
06-29-2009, 11:43 AM
I'm following along because I want to do something similar. :)

Question: what customfield is this fetching? The code looks like it's for customfield6 - is that right? I'm confused because you also mentioned displaying field17.

What would I need to change to fetch a different customfield?

DragonBlade
06-29-2009, 12:08 PM
Eeeeek! field6 was for me testing it on my boards. XP I'll go edit that for 17.

But yes, that's the gist of it. :3

chris1979
06-29-2009, 12:13 PM
Field6 is actually what I want for my forum. You are probably psychic. :D

Now I have two other questions:

1) I want to fetch two fields - field6 and field7, and display them both. (It's firstname / surname.) Do I need to have two plugins or can I edit the code to fetch both at once?

2) I am using the advanced threadbit mod and I think there's a conflict. When the mod is enabled, the second plugin (to displaying the customfield) doesn't have anything to hook to. (It works fine when I turn the advanced threadbit mod off.) Is it possible to just insert the code into my template? Something like $marital_status?

DragonBlade
06-29-2009, 12:54 PM
1)

It's actually BETTER to fetch both at once. :3

Notice the query line,$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);For you to have both fields fetched, try$my_query = sprintf("SELECT thread.threadid, userfield.field6 AS thisfield, userfield.field7 AS thatfield, FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);

Now, to make those values USEABLE, try this code:
$my_field6_threadids = array();
$my_field7_threadids = array();
$my_query = sprintf("SELECT thread.threadid, userfield.field6 AS thisfield, userfield.field7 AS thatfield FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$my_result = $vbulletin->db->query_read($my_query);
while ($my_row = $vbulletin->db->fetch_array($my_result))
{
$my_field6_threadids[$my_row['threadid']] = $my_row['thisfield'];
$my_field7_threadids[$my_row['threadid']] = $my_row['thatfield'];
}



Now, to make the variable easy to access in the templates, use THIS instead for your plugin in "threadbit_display":
$my_field6 = $my_field6_threadids[$thread['threadid']];
$my_field7 = $my_field7_threadids[$thread['threadid']];








2)

No worries! Using those values above, go into your "threadbit" template, and just plug in the values wherever the hell you want. :3

For example, this is USUALLY (without modifications) the part of the threadbit template that is the FIRST column: <td class="alt1" id="td_threadstatusicon_$thread[realthreadid]">
$thread[openclose_editable]
<img src="$stylevar[imgdir_statusicon]/thread$thread[statusicon].gif" id="thread_statusicon_$thread[realthreadid]" alt="<if condition="$show['threadcount']"><phrase 1="$thread[dot_count]" 2="$thread[dot_lastpost]">$vbphrase[have_x_posts_in_thread_last_y]</phrase></if>" border="" />
</td>If I wanted to put your Field 6 in that column, I'd just do it as so: <td class="alt1" id="td_threadstatusicon_$thread[realthreadid]">
$thread[openclose_editable]
$my_field6
<img src="$stylevar[imgdir_statusicon]/thread$thread[statusicon].gif" id="thread_statusicon_$thread[realthreadid]" alt="<if condition="$show['threadcount']"><phrase 1="$thread[dot_count]" 2="$thread[dot_lastpost]">$vbphrase[have_x_posts_in_thread_last_y]</phrase></if>" border="" />
</td>

Bada bing, bada boom!



Now, I've never used this advanced threadbit thing, but it PROBABLY uses the threadbit template, so... yar. :3

The BEST way to go about it is to avoid editing your templates directly if you can avoid it. But if you can't... well, that's what the template editor is there for. :3

chris1979
06-29-2009, 01:18 PM
It works!!!!!!!!!!!!!!!! :) :) :) :)

I have been trying to do this for ages so thanks - I would never have worked it out without your help.

--------------- Added 1246285171 at 1246285171 ---------------

Next I am going to work out how to do the same for the list of private messages :)

DragonBlade
06-29-2009, 01:23 PM
Good luck, and if you need help, don't hesitate to ask. :3

chris1979
06-29-2009, 01:34 PM
Thanks!

I might never leave you alone now. :)

On threadbit, do you know what I'd need to change to also get the last poster's cutomfields? (The first code works for the first poster - so I want something else for the last post column.)

For the list of private messages, do you know what code I should use there?

DragonBlade
06-29-2009, 02:20 PM
For the last poster, you'd need another query, slightly different from the first. Unfortunately, by default, vBulletin only stores the last poster's NAME, and not their user ID, so we have to look them up by name. (Well, not TOO unfortunate, I suppose, but working with numbers is so much easier, IMO.)

Anyways, THAT query would look something like this:
$my_lastposter_query = sprintf("SELECT thread.threadid, userfield.field1 AS myfield1, userfield.field2 AS myfield2, userfield.field3 AS myfield3, userfield.field4 AS myfield4 FROM thread LEFT JOIN userfield ON(thread.lastposter=user.username) LEFT JOIN userfield ON(user.userid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);

Note the extra JOIN in there--that's because the "userfield" table doesn't have the "username", and the "thread" table doesn't include the last poster's "userid". :(

This COULD potentially be bad on performance, but I honestly don't know just how bad it would be. The alternative option would be to add a field to the thread table "lastpostuserid", re-code the thread update to make it so the userid of the last poster is included in the update (like the username is already), and then update all threads on your forum. That's the BEST way to do it, but is much more complex, and if you have a lot of threads on your forum, it could take quite a while to update them all. (If you did NOT update them, though, they would become updated the next time someone posted in them.) That way, we can reduce it to a single JOIN.



Anyways, I'm blabbing on about insignificant details, probably.

For the Private Messages... Well, lemme take a looksee and I'll post again in a few.

--------------- Added 1246291796 at 1246291796 ---------------

Whoo, boy, PMs are a different ballgame, here.

As with the last poster bit for threads, we had to JOIN three tables together here: pm, pmtext, and userfield. See, the User ID we WANT is who the PM is from. This information is only on the pmtext table. However, two and a half things we need to sift the results by are only on the pm table, and not the pmtext table. (The "half" is that "$readstatus" varaible that is sometimes show and sometimes not, depending upon the user's input.) Finally, the data we want to pull in order to display is on the userfield table. Thus, the three JOINed tables.

Next bit of complication arose because there wasn't a decent place (read: "hook location") to put a plugin, so we had to improvise by pre-running a few bits of code that will run AGAIN after the query. (See the comment in the code itself.)



All righty. The "hook location" we'll be using for this plugin is "private_messagelist_filter". I'm sure by now you can fill out all the other fields on your own, except for the Plugin Code, which is below:// ***************************** vB Stuff *************************************
// TECHIE ** The lines below are actually already run in the vB page. **
// NOTE: ** However, they are run AFTER our hook, and we need them run **
// ** BEFORE we create our query. Basically, these will get **
// ** executed twice. That's okay, though, they're not really **
// ** resource-intensive or anything. **
// ************************************************** **************************
sanitize_pageresults($totalmessages, $vbulletin->GPC['pagenumber'], $vbulletin->GPC['perpage'], $vbulletin->options['pmmaxperpage'], $vbulletin->options['pmperpage']);
$startat = ($vbulletin->GPC['pagenumber'] - 1) * $vbulletin->GPC['perpage'];
$perpage = $vbulletin->GPC['perpage'];
$pagenumber = $vbulletin->GPC['pagenumber'];
$need_sql_calc_rows = ($search['searchtitle'] OR $search['searchuser'] OR $search['startdate'] OR $search['enddate'] OR $search['read']);
$readstatus = array(0 => '', 1 => '= 0', 2 => '> 0', 3 => '< 2', 4 => '= 2');
$readstatus = ($search['read'] == 0 ? '' : 'AND pm.messageread ' . $readstatus[$search['read']]);
// *************************** End vB Stuff ***********************************


// ***************************** Our Stuff ************************************
// TECHIE ** For each field you want, you'll want an array to capture the **
// NOTE: ** value and assign it to the array with the KEY being the pmid **
// ** value and the VALUE being the field value. **
// ************************************************** **************************
$my_field1_pmids = array();
$my_field2_pmids = array();
$my_field3_pmids = array();
$my_field4_pmids = array();
$pm_userfield_query = sprintf("
SELECT " . ($need_sql_calc_rows ? 'SQL_CALC_FOUND_ROWS' : '') . "
pm.pmid,
userfield.field1 AS myfield1,
userfield.field2 AS myfield2,
userfield.field3 AS myfield3,
userfield.field4 AS myfield4
" . iif($vbulletin->options['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
FROM pm
LEFT JOIN pmtext ON(pmtext.pmtextid=pm.pmtextid)
LEFT JOIN userfield ON(userfield.userid=pmtext.fromuserid
" . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
WHERE pm.userid=%d AND pm.folderid=%d" .
($search['searchtitle'] ? " AND pmtext.title LIKE '%" . $vbulletin->db->escape_string($search['searchtitle']) . "%'" : '') .
($search['searchuser'] ? " AND pmtext.fromusername LIKE '%" . $vbulletin->db->escape_string($search['searchuser']) . "%'" : '') .
($search['startdate'] ? " AND pmtext.dateline >= $search[startdate]" : '') .
($search['enddate'] ? " AND pmtext.dateline <= $search[enddate]" : '') . "
$readstatus
LIMIT $startat, " . $vbulletin->GPC['perpage'] . "
", $vbulletin->userinfo['userid'], $vbulletin->GPC['folderid']);
$pm_userfield_result = $vbulletin->db->query_read($pm_userfield_query);
while ($pm_userfield_row = $vbulletin->db->fetch_array($pm_userfield_result))
{
$my_field1_pmids[$pm_userfield_row['pmid']] = $pm_userfield_row['myfield1'];
$my_field2_pmids[$pm_userfield_row['pmid']] = $pm_userfield_row['myfield2'];
$my_field3_pmids[$pm_userfield_row['pmid']] = $pm_userfield_row['myfield3'];
$my_field4_pmids[$pm_userfield_row['pmid']] = $pm_userfield_row['myfield4'];
}WHEW! Quite a lot there! It may be difficult to understand exactly what is going on in the query, but try to trudge your way through it anyhow. :3

(Again, this particular bit is as-of-yet untested, so I may have typos somewhere in there.)





The NEXT plugin you're going to create is at the hook, "private_messagelist_messagebit". This is basically right before the template is called. All we're doing with this plugin is making it easier to call the field variables in the template.$my_field1 = $my_field1_pmids[$pm['pmid']];
$my_field2 = $my_field2_pmids[$pm['pmid']];
$my_field3 = $my_field3_pmids[$pm['pmid']];
$my_field4 = $my_field4_pmids[$pm['pmid']];
Now, in the template, the varaibles you'll be calling are those $my_field1, $my_field2, etc. :)



Now for the template itself. It's pm_messagelistbit, and you can use those $my_fieldN variables anywhere you want in there.



.....I hope. :awe:



And demmit, we need an "awesome" smiley here. https://vborg.vbsupport.ru/

Mellymonster
06-30-2009, 03:05 AM
Okays, seems I made a spelling error AND added in an un-needed comma. XP

I tested this out on my forum and it works.



PLUGIN #1:// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
{$marital_status_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}
NOTE: The "," in the "WHERE thread.threadid IN" statement is now omitted.
NOTE2: I spelled "status" as "statis" in one variable. XD Oopsie.

See how that works out for ya.

For Marital Status Thread Display this right?
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']];

For Marital Status Thread Query, this?
($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false;

// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
{$marital_status_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}

I'm still getting the big error.

mikey12561
06-30-2009, 03:41 AM
kk just to let you know I change it with the new code you gave us and I still got the same error.

Speedy131
06-30-2009, 09:54 AM
don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.

DragonBlade
06-30-2009, 02:26 PM
For Marital Status Thread Display this right?
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']];

For Marital Status Thread Query, this?
($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false;

// Query to check if/what threadowner's marital status is
$marital_status_threadids = array();
$marital_status_threads_query = sprintf("SELECT thread.threadid, userfield.field17 AS maritalstatus FROM thread LEFT JOIN userfield ON(thread.postuserid=userfield.userid) WHERE thread.threadid IN (0%s)", $ids);
$marital_status_threads_result = $vbulletin->db->query_read($marital_status_threads_query);
while ($marital_status_threads_row = $vbulletin->db->fetch_array($marital_status_threads_result))
{$marital_status_threadids[$marital_status_threads_row['threadid']] = $marital_status_threads_row['maritalstatus'];}

I'm still getting the big error.

kk just to let you know I change it with the new code you gave us and I still got the same error.





Hmmm... There is no doubt that it is my code that is causing your error. Line 866 in forumdisplay is where the forumdisplay_query hook is located, and that's where I told you to make that first plugin. I just can't seem to figure out WHY.

This field17 of yours, it's just a string, correct? Like a link to an image or something, not the actual image data, right? I'm not understanding why it's trying to allocate such a huge chunk of memory. I mean, if it was actual binary data (like if you stored the image itself on the database) I guess I could understand...

Could you do me a favour and select five or ten random users, get their userid, run this query (phpMyAdmin, the vBulletin run query bit, or even by the command line, it matters not where), and paste the output for me?

SELECT field17 AS maritalstatus FROM userfield WHERE userid IN (XXX1,XXX2,XXX3,...,XXXN)
Replace the XXX1,XXX2,XXX3,...,XXXN with the userids. An example could be "IN (34562,43529,11324,74923,2514)".

--------------- Added 1246376862 at 1246376862 ---------------

don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.

This can actually be done with just a little modification to the $hook_query_fields and $hook_query_joins variables for the call to threads. :)]


You will be making a plugin on the hook forumdisplay_query. Title it however you want.

Now, what you want is to join the user table with the thread table, so that you can select values from the user table. The specific field you want is membergroupids. PLEASE NOTE, however, that if for some reason you change around the users' PRIMARY usergroup (something I never do), that this will be an entirely different story! I'm just assuming here that you use secondary usergroups, so let me know if that's not the case!

ALSO NOTE, this first code is assuming that you want to use more than the usergroup '22' at some point in the future. We can uncomplicate things (heh, kind of) if you KNOW that you will only ever want to use usergroup 22, and I'll explain that a bit later.

So, here's the code that needs to go in the plugin, assuming the above:$hook_query_fields .= ', user.membergroupids '; // This adds the membergroupids field to the data returned
$hook_query_joins .= ' LEFT JOIN user ON(thread.postuserid=user.userid) '; // This adds the user table to the query, and searches only the record that matches the postuserid


Now, this data will be returned in the $thread variable as $thread['membergroupids']. The data itself is a comma-separated list, like "2,5,34,22,78", so in out next plugin, we'll explode that into an array, which will be a bit easier for us to handle with PHP.



Our NEXT plugin goes on the hook, threadbit_display. Title it what you want. :3

The code we'll use will make that list into an array, and will then search the array for the value '22'.
$thread['membergroupids'] = explode(',', $thread['membergroupids']);
$isgroup22 = in_array(22, $thread['membergroupids']);
Now, $isgroup22 will be true if the usergroup 22 is included. You can use this variable in an <if condition="$isgroup22">Print this<else />Print That</if> statement in the template, OR (if you have a variable you want to append it to) you can modify it directly in the plugin.

Consider this alternative to the above plugin:
$thread['membergroupids'] = explode(',', $thread['membergroupids']);
if (in_array(22, $thread['membergroupids'])) {$thread['postusername'] .= '<img src="/my/supercool/usergroup/image.png" />';}
This will just append the image to the username for the thread starter without the need for touching templates. :3






I'll be back in a bit with explanation for if you ONLY ever wanted to use usergroup 22.

--------------- Added 1246382814 at 1246382814 ---------------

Y'know, I really hate this effing "Auto-merged Double-Post" crap. :( A lot of posts can be read better if their content was seperated better.

* DragonBlade shakes a fist in defiance of the Admins. And is then struck down with the Almighty Ban Hammer. https://vborg.vbsupport.ru/external/2009/06/1.jpg



ANYWAYS, back to what I was saying. I went over it, and really, the efficiency wouldn't be much better in searching only for usergroup22 in the query, so what I posted is probably best. HOWEVER, there might be a slight bug with the second plugin.

The line, $thread['membergroupids'] = explode(',', $thread['membergroupids']);Assumes that there will be a comma-seperated list, but this is not always the case, so a better way to write it would be:$thread['membergroupids'] = ($thread['membergroupids']) ? explode(',', $thread['membergroupids']) : array();This makes it so that if there is no value in $thread['membergroupids'], it will return an empty array. It would do the same the other way, but could also throw warnings that would ugly up your page. XP

Speedy131
06-30-2009, 07:43 PM
DragonBlade, you are awesome ! :up::up:

Worked exactly as you described and it's just what I needed, I'm so happy now :)
Now I also (somewhat) understand that whole hooks thing, that's actually pretty nice.

Once again, thank you very very much :D

Mellymonster
07-01-2009, 04:49 PM
Well I used the gender icon in post bit code thing for the marital status...

<!-- Start Gender On/Off Customization -->
<if condition="$bbuserinfo['field18'] != 'Yes'">
<if condition="$post[field17]"> <img src="$stylevar[imgdir_misc]/$post[field17].gif" alt="$post[field17]" /></if>
</if>
<!-- End Gender On/Off Customization -->

It has gender in it cus I didn't know if changing it would hurt anything so I kept it like that.

Mellymonster
07-05-2009, 04:56 AM
DragonBlade, can you help me with this? Please :)

deluxmall
11-20-2009, 12:41 PM
don't want to hijack this thread or anything, but just wanted to ask if i only want to look for the usergroup(s) the threadstarter belongs to, do I also need to work with all that code?

I want to show an image in the threadbit, next to the username of the threadstarter if the threadstarter belongs to usergroup 22 ... that usergroup is an "additional" usergroup.

that is what I want to do, any solution??