![]() |
Is there a way..
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 |
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 |
This should be achievable with custom profile fields.
|
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 [DATE]1246032424[/DATE] at [TIME]1246032424[/TIME] --------------- 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. |
This is a wild shot in the dark... but in the forumdisplay template, there is
Code:
$vbphrase[thread] / $vbphrase[thread_starter] |
hmm that didn't work I added this
Code:
<if condition="$post[field17]"> <img src="$stylevar[imgdir_misc]/$post[field17].gif" alt="$post[field17]" /></if> |
i'm pretty sure $post[] will only work in postbit templates... (maybe showthread?)
I doubt it would work in forumdisplay |
oh right lol, but showthread didn't work either.
|
Quote:
|
Quote:
Quote:
|
Use $bbuserinfo rather that $post. $post only works in the postbit I think.
|
so like this
Code:
<if condition="$bbuserinfo[field17]"> <img src="$stylevar[imgdir_misc]/$bbuserinfo[field17].gif" alt="$bbuserinfo[field17]" /></if> Its not working :( |
Try:
Code:
<if condition="$bbuserinfo['field17']"> <img src="$stylevar[imgdir_misc]/$bbuserinfo[field17].gif" alt="$bbuserinfo[field17]" /></if> |
I tried it and it doesn't work either :(
|
ok, where are you putting it, and what is happening?
|
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. :) |
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 [DATE]1246157167[/DATE] at [TIME]1246157167[/TIME] --------------- Quote:
|
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: PHP Code:
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: PHP Code:
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 PHP Code:
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 [DATE]1246227765[/DATE] at [TIME]1246227765[/TIME] --------------- Quote:
PHP Code:
PHP Code:
|
1 Attachment(s)
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. |
I just wanted to verify that he is one of my techies...
|
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. |
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? |
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 |
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? |
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]"> HTML Code:
<td class="alt1" id="td_threadstatusicon_$thread[realthreadid]"> 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 |
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 :) |
Good luck, and if you need help, don't hesitate to ask. :3
|
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? |
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. https://vborg.vbsupport.ru/ |
Quote:
Code:
$thread['postusername'] .= $marital_status_threadids[$thread['threadid']]; Code:
($hook = vBulletinHook::fetch_hook('forumdisplay_query')) ? eval($hook) : false; |
kk just to let you know I change it with the new code you gave us and I still got the same error.
|
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. |
Quote:
Quote:
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? Code:
SELECT field17 AS maritalstatus FROM userfield WHERE userid IN (XXX1,XXX2,XXX3,...,XXXN) --------------- Added [DATE]1246376862[/DATE] at [TIME]1246376862[/TIME] --------------- Quote:
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: PHP Code:
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'. PHP Code:
Consider this alternative to the above plugin: PHP Code:
I'll be back in a bit with explanation for if you ONLY ever wanted to use usergroup 22. --------------- Added [DATE]1246382814[/DATE] at [TIME]1246382814[/TIME] --------------- 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. [high]* 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[/high] 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, PHP Code:
PHP Code:
|
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 |
Well I used the gender icon in post bit code thing for the marital status...
PHP Code:
|
DragonBlade, can you help me with this? Please :)
|
Quote:
|
All times are GMT. The time now is 07:40 AM. |
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:
|