The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Comparing Friend UserID
Hello, I am in the process of writing a script which highlights buddy posts. I'm having trouble however passing a condition to only highlight the buddies and not everyone.
I have tried several conditionals, all either ending in showing no posts, or all posts. Below are variations of code I have used. In myphp file: When pulling information (used from misc.php): PHP Code:
PHP Code:
PHP Code:
Code:
<vb:if condition="is_array($memberpost[userid], array($postbuddies))"></vb:if> I hope my post makes sense, it's very late night for me and at this point I feel like my mind is going bonkers. Than you kindly for any help. |
#2
|
|||
|
|||
You don't need array() in the conditional, it should be:
Code:
<vb:if condition="is_array($memberpost[userid], $postbuddies)"></vb:if> But that will only work if you register $postbuddies to the template. A way around that would be to add it to an array that is already registered, like: Code:
$memberpost[postbuddies] = $postbuddies; then Code:
<vb:if condition="is_array($memberpost[userid], $memberpost[postbuddies])"></vb:if> I should also mention that rendered posts are cached, so that may also give you trouble. With the post caching, you can't really have the background change based on something that is specific to the user viewing the post. |
#3
|
|||
|
|||
Hi kh99, thank you for your response. This is not the first time you have helped me and I'm very thankful.
If I do not include the array() in the conditional, I receive a malformed conditional error when compiling. Code:
<vb:if condition="in_array($memberpost[userid], $memberpost[postbuddies])"> Code:
<vb:if condition="is_array($memberpost[userid], $memberpost[postbuddies])"> PHP Code:
|
#4
|
|||
|
|||
Sorry, one thing I didn't notice - you should be using in_array(), not is_array().
Which hook is your plugin using, and which template is your conditional in? |
#5
|
|||
|
|||
Hi, I'm using misc_buddylist_start for the hook. I'm using a module from vbadvanced cmps, more or less similar to the "News" module if you're familiar with it.
Thanks! |
#6
|
|||
|
|||
I continue to have difficulty with this. Any input? Thanks!
|
#7
|
|||
|
|||
One very important thing I missed the first time around - you can't directly use the return value of query_read_slave(), it won't be an array. If you're only expecting one row from your query, you should call query_read_first(), which will return an array representing the first row returned from the query.
|
#8
|
|||
|
|||
Excellent, thank you kh99. I'm going to try this out.
--------------- Added [DATE]1346099203[/DATE] at [TIME]1346099203[/TIME] --------------- Thank you kh99, I have had more success. I wanted to verify whether or not I was pulling the information correctly through the php hook. I used print_r to see the array. When using query_first(); unfortunately their was no return. When using query_ready() was able to return the array however. Array ( [0] => 111 ) Array ( [0] => 2379 ) Array ( [0] => 103 ) Array ( [0] => 28 ) Array ( [0] => 6 ) Array ( [0] => 49 ) Array ( [0] => 192 ) Array ( [0] => 2399 ) PHP Code:
When comparing in the template however, I receive this error: Code:
<vb:if condition="in_array($comment[buddylist], $comment[userid])">A friend posted!</vb:if> Code:
The following error occurred when attempting to evaluate this template: %1$s This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. Thanks for your continued support. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|