The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#21
|
||||
|
||||
![]()
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: PHP Code:
NOTE2: I spelled "status" as "statis" in one variable. XD Oopsie. See how that works out for ya. |
#22
|
|||
|
|||
![]()
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? |
#23
|
||||
|
||||
![]()
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 |
#24
|
|||
|
|||
![]()
Field6 is actually what I want for my forum. You are probably psychic.
![]() 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? |
#25
|
||||
|
||||
![]()
1)
It's actually BETTER to fetch both at once. :3 Notice the query line, PHP Code:
PHP Code:
PHP Code:
Now, to make the variable easy to access in the templates, use THIS instead for your plugin in "threadbit_display": PHP Code:
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: HTML Code:
<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> HTML Code:
<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> 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 |
#26
|
|||
|
|||
![]()
It works!!!!!!!!!!!!!!!!
![]() ![]() ![]() ![]() I have been trying to do this for ages so thanks - I would never have worked it out without your help. --------------- Added [DATE]1246285171[/DATE] at [TIME]1246285171[/TIME] --------------- Next I am going to work out how to do the same for the list of private messages ![]() |
#27
|
||||
|
||||
![]()
Good luck, and if you need help, don't hesitate to ask. :3
|
#28
|
|||
|
|||
![]()
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? |
#29
|
||||
|
||||
![]()
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: PHP Code:
![]() 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 [DATE]1246291796[/DATE] at [TIME]1246291796[/TIME] --------------- 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: PHP Code:
(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. PHP Code:
![]() 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. |
#30
|
|||
|
|||
![]() Quote:
Code:
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']]; Code:
($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'];} |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|