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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2015, 12:44 AM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default if post count conditional

Hi everyone,

Fairly sure this is a simple request, but can't quite figure out how to do it.

I want to include a conditional statement in a users postbit if the user has made more then X posts. I know I can get the total number of posts from the user using this {vb:raw post.posts}

That returns a number like 1,784

How can use that variable in a conditional though?

Essentially 'if {vb:raw post.posts} > 1000' Do this.....

Can anyone help out? What's the correct syntax?

Cheers,
hilaryl
Reply With Quote
  #2  
Old 03-25-2015, 01:53 AM
Elite_360_'s Avatar
Elite_360_ Elite_360_ is offline
 
Join Date: Nov 2012
Location: New Hampshire
Posts: 518
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HTML Code:
<vb:if condition="$post['posts'] > 1000">
Code Here
</vb:if>
Reply With Quote
  #3  
Old 03-25-2015, 04:00 AM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the code.

Unfortunately this isn't working though, and I'm fairly sure it's because '$post['posts']' is equal to a number with a comma in it. As in it's equal to '1,060'.

How can I turn '1,060' into '1060' so I can compare the numbers?
Reply With Quote
  #4  
Old 03-25-2015, 07:21 PM
Elite_360_'s Avatar
Elite_360_ Elite_360_ is offline
 
Join Date: Nov 2012
Location: New Hampshire
Posts: 518
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Make a new plugin

Product = vBulletin

Hook Location = postbit_display_complete

Title = what ever you want for a tiltle

Execution Order = 5

Plugin PHP Code

PHP Code:

$post
['new_user_posts'] = str_replace(','''$post['posts']); 

Plugin is Active = check to Yes


New Condition

HTML Code:
<vb:if condition="$post['new_user_posts'] > 1000">
Code Here
</vb:if>
Reply With Quote
2 благодарности(ей) от:
Lynne, nolimitreef
  #5  
Old 03-25-2015, 10:28 PM
hilaryl hilaryl is offline
 
Join Date: Jan 2006
Location: Brisbane, Australia
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fantastic - thanks for being so thorough with your explanation.

I'll give it a go shortly and let you know how I go.

Thanks,
hilaryl

--------------- Added [DATE]1427333234[/DATE] at [TIME]1427333234[/TIME] ---------------

Works like a charm!

Actually ended up tweaking it a bit and added what I wanted into another template_hook so I don't have to alter the post_bit template.

Full plugin code below:

HTML Code:
$new_user_posts = str_replace(',', '', $post['posts']);

if ($new_user_posts > 500) {
$template_hook['postbit_userinfo_right_after_posts'] .= '<!--<dt></dt><dd>' . $new_user_posts . '</dd>-->';
}
Reply With Quote
2 благодарности(ей) от:
Lynne, nolimitreef
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 07:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07036 seconds
  • Memory Usage 2,211KB
  • 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
  • (3)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (4)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete