Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2005, 01:26 AM
zetetic's Avatar
zetetic zetetic is offline
 
Join Date: Apr 2004
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default post pop-up menu conditional

I'm trying to add something to the post popup menu that's conditional based on whether the user is on your buddylist. This is as close as I can guess, but it doesn't seem to work:

<if condition="in_array($post[userid], $bbuserinfo[buddylist])">

Any idea how to make that work?

Okay after many hours of poking around and trying different things, at this point I'm guessing my question above doesn't even make sense. I would think what I'm trying to do is very simple, but so far it doesn't seem to be. I want to put a conditional in the postbit template so that "Add {user} to your buddylist" becomes "Remove {user} from your buddylist" if they're already your buddy. At this point I think I have a better chance of building a car that gets 1000 miles to a gallon of water.
Reply With Quote
  #2  
Old 06-04-2005, 05:28 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The buddy list isn't an array, it's a list of userIDs seperated with spaces. You'll have to use another function.
Reply With Quote
  #3  
Old 06-04-2005, 12:23 PM
Cloudrunner's Avatar
Cloudrunner Cloudrunner is offline
 
Join Date: May 2003
Location: Butte, MT
Posts: 635
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tmhall
I'm trying to add something to the post popup menu that's conditional based on whether the user is on your buddylist. This is as close as I can guess, but it doesn't seem to work:

<if condition="in_array($post[userid], $bbuserinfo[buddylist])">

Any idea how to make that work?

Okay after many hours of poking around and trying different things, at this point I'm guessing my question above doesn't even make sense. I would think what I'm trying to do is very simple, but so far it doesn't seem to be. I want to put a conditional in the postbit template so that "Add {user} to your buddylist" becomes "Remove {user} from your buddylist" if they're already your buddy. At this point I think I have a better chance of building a car that gets 1000 miles to a gallon of water.
Offa the top of me noggin (I'm not near a computer with testing capabilities right now)...

PHP Code:
$buddylist = array(); //initializes the variable $buddylist to be an array
$buddylist explode(' '$bbuserinfo['buddylist']); //This will put the buddylist id's into the array called $buddylist with $buddylist[0] being the first id in the array. 
and then you can call the conditional:

Code:
<if condition="in_array($post[userid], $buddylist)">
  Remove $post[username] from your buddylist<br />
<else />
  Add $post[username] to your buddylist<br />
</if>
My thoughts right now (again, no test availability) would be to put the $buddylist php code in your ./global.php file.
Reply With Quote
  #4  
Old 06-04-2005, 01:27 PM
zetetic's Avatar
zetetic zetetic is offline
 
Join Date: Apr 2004
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your replies, guys.

I came pretty close to that same solution myself last night, except I didn't initialize the array first* and I was putting the code in showthread.php instead of global.php. Unfortunately I get the same results either way:

Code:
Warning: in_array(): Wrong datatype for second argument in /includes/functions_showthread.php(640) : eval()'d code on line 213
For testing purposes I put print_r($buddylist); in showthread.php and it comes up:

Code:
Array
(
    [0] => 2
)
(I'm on a test server and have one person on my buddylist, userid = 2)


*Is that really necessary? For some reason I thought it wasn't.
Reply With Quote
  #5  
Old 06-04-2005, 02:52 PM
Cloudrunner's Avatar
Cloudrunner Cloudrunner is offline
 
Join Date: May 2003
Location: Butte, MT
Posts: 635
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tmhall
Thanks for your replies, guys.

I came pretty close to that same solution myself last night, except I didn't initialize the array first* and I was putting the code in showthread.php instead of global.php. Unfortunately I get the same results either way:

Code:
Warning: in_array(): Wrong datatype for second argument in /includes/functions_showthread.php(640) : eval()'d code on line 213
For testing purposes I put print_r($buddylist); in showthread.php and it comes up:

Code:
Array
(
    [0] => 2
)
(I'm on a test server and have one person on my buddylist, userid = 2)


*Is that really necessary? For some reason I thought it wasn't.
found my goof...sorry

PHP Code:
<if condition="in_array($post['userid'], $buddylist)">
  
Remove $post[usernamefrom your buddylist<br />
<else />
  
Add $post[usernameto your buddylist<br />
</if> 
note the singlequote in the conditional array $post.

see if that helps any,
Reply With Quote
  #6  
Old 06-04-2005, 04:33 PM
zetetic's Avatar
zetetic zetetic is offline
 
Join Date: Apr 2004
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Unfortunately it's still not working.

Just to be clear, I added this to the bottom of global.php:

PHP Code:
$mybuddylist = array();
$mybuddylist explode(' '$bbuserinfo['buddylist']); 
And this to the postbit:

HTML Code:
<tr><td><if condition="in_array($post['userid'], $mybuddylist)">
  Remove $post[username] from your buddylist<br />
<else />
  Add $post[username] to your buddylist<br />
</if></td></tr>
And this to showthread.php:

PHP Code:
echo "<pre>";
print_r($mybuddylist);
echo 
"</pre>"
And this is what I get at the top of the page (with one buddy, userid = 2):

Code:
Warning: in_array(): Wrong datatype for second argument in /includes/functions_showthread.php(640) : eval()'d code on line 213

Warning: in_array(): Wrong datatype for second argument in /includes/functions_showthread.php(640) : eval()'d code on line 213

Warning: in_array(): Wrong datatype for second argument in /includes/functions_showthread.php(640) : eval()'d code on line 213

Array
(
    [0] => 2
)
Reply With Quote
  #7  
Old 06-04-2005, 07:46 PM
Cloudrunner's Avatar
Cloudrunner Cloudrunner is offline
 
Join Date: May 2003
Location: Butte, MT
Posts: 635
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this one then, since it's looking for an integer in the array I think...still away from testing computer...

PHP Code:
$mybuddylist = array();
$mybuddylist trim($bbuserinfo['buddylist']);
 
$mybuddylist explode(' '$mybuddylist);
foreach (
$mybuddylist AS $key => $value){
    
$mybuddylist[$key] = intval($value);

That's about the extent of my abilities until I can get back to my testing server...
Reply With Quote
  #8  
Old 06-04-2005, 08:08 PM
zetetic's Avatar
zetetic zetetic is offline
 
Join Date: Apr 2004
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nope, didn't work unfortunately. Exactly the same results.
Reply With Quote
  #9  
Old 06-04-2005, 08:38 PM
Cloudrunner's Avatar
Cloudrunner Cloudrunner is offline
 
Join Date: May 2003
Location: Butte, MT
Posts: 635
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well crap dude, I'm stuck then....

Not quite sure where to go from there...
Quote:
Originally Posted by tmhall
Nope, didn't work unfortunately. Exactly the same results.
Reply With Quote
  #10  
Old 06-05-2005, 01:51 AM
zetetic's Avatar
zetetic zetetic is offline
 
Join Date: Apr 2004
Posts: 338
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Cloudrunner
Well crap dude, I'm stuck then....

Not quite sure where to go from there...
Hey no problem, man. I'm not really sure what to do either. This seems like it would be such a simple thing... thanks for giving it a shot anyway.

Okay I stumbled on a solution, so here it is for posterity.

I'm not gonna bother posting it in mini-mods since there's probably an easier way:

Find in includes/functions_showthread.php:
PHP Code:
$show['messageicon'] = iif($post['iconpath'], truefalse); 
Add above:

PHP Code:
    // set-up for buddylist conditional - postbit
    
$isbuddy explode(' '$bbuserinfo['buddylist']);
    
    if (
in_array($post['userid'], $isbuddy))
    {
        
$isbuddy true;
    }
    else
    {
        
$isbuddy false;
    } 
Find in postbit template:

HTML Code:
<if condition="$post['userid']">
	<tr><td class="vbmenu_option"><a href="profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$post[userid]"><phrase 1="$post[username]">$vbphrase[add_x_to_buddy_list]</phrase></a></td></tr>
	</if>
Replace with:

HTML Code:
<if condition="($bbuserinfo['userid'] AND ($post[userid] != $bbuserinfo['userid']))">
<if condition="($isbuddy == false)">
		<tr><td class="vbmenu_option"><a href="$vboptions[bburl]/profile.php?$session[sessionurl]do=addlist&amp;userlist=buddy&amp;u=$userinfo[userid]"><phrase 1="$post[username]">$vbphrase[add_x_to_buddy_list]</phrase></a></td></tr>
		<else />
		<tr><td class="vbmenu_option"><a href="$vboptions[bburl]/profile.php?$session[sessionurl]do=removelist&amp;userlist=buddy&amp;u=$userinfo[userid]"><phrase 1="$post[username]">$vbphrase[remove_x_from_buddy_list]</phrase></a></td></tr>
		</if>
</if>
Add this postbit phrase:

remove_x_from_buddy_list
Remove {1} from your Buddy List
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04241 seconds
  • Memory Usage 2,290KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (3)bbcode_html
  • (7)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete