The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
First, I've never created a plugin before, so please be gentle!
$userinfo[posts] and $post[posts] outputs a user's posts as a string (why, I don't know). This makes it useless for doing comparisons. I need to create a plugin that will take that output, convert it to a string, and store it in a variable so I can do comparison. Where exactly do I begin? Is there something out there that does something similar that I can reverse engineer? Do you have any pointers on how to get going? |
#2
|
|||
|
|||
![]()
Are you sure? I thought vB converted them to integers. Otherwise its a string because MySQL returns data from a query as an array of strings (it doesn't convert them to integers automatically). You can use the intval() function to convert a string to a integer.
|
#3
|
|||
|
|||
![]()
Plugins are pure php, so there is no need to convert it by youreself. Php has no types if a variable contains a number you can use it as such.
// This one will use it as number if( $userinfo[posts] >5){ } // THis will use it as String echo("Posts:" . $userinfo[posts] ); |
#4
|
|||
|
|||
![]()
Opserty, I'm pretty sure. You can read my thread on vbulletin.com about it. In short, I used the conditional below and it only worked on threads above 2000. If someone can explain why that is, I'd love to know.
Code:
<if condition="$post[posts] >= '1000'"> >1000<else /> $post[posts]</if> Way 1 I override the behavior of $userinfo[posts] and $post[posts] within a plugin. This is ideal because I could change them to output the number below 1000 and just > 1000 above. There would be no template edits. Way 2 Create new variables with the relevant post count and edit the templates. Are those two variables even accessible by a plugin? Are they available everywhere or just within a certain hook? If I'm conceptually off, please let me know. I really appreciate the feedback. If I can find a way to do this that's straightforward and doesn't require edits, it would make a great mod. |
#5
|
|||
|
|||
![]()
You could use str_replace() on the variable:
PHP Code:
|
#6
|
|||
|
|||
![]()
THANK YOU! I created three plugins, one for the memberlist_resultbit, profile_complete (or whatever it's called), and postbit_complete. It worked like a charm and all the conditionals are now functioning. At some point in time, I may just overwrite the string rather than using template conditionals to make upgrading easier, but at least it works. I really appreciate the help. Hopefully this will ease some of the fluff posts that have become so common.
|
#7
|
|||
|
|||
![]()
No problem, the only reason I chose not to overwrite the variable is that it is used in the template in its comma separated form (10,000 e.t.c.) in the postbit template.
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|