vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Template conditional for post count (https://vborg.vbsupport.ru/showthread.php?t=178951)

Mum 05-12-2008 01:53 AM

Template conditional for post count
 
I am wanting to show something to people who have made over 5 posts in the last 24 hours. For inside a template.

Can anyone help please?

Boofo 05-12-2008 02:18 AM

Try ths:

HTML Code:

<if condition="$post['postcount'] > '5'">
do this
<else />
do that
</if>

or

HTML Code:

<if condition="$post['postcount'] > '5'">
do this
</if>


Mum 05-12-2008 02:46 AM

Boofo - isn't that only going to do if they have more than 5 posts? I want to know if they ahve done 5 posts in the last 24 hours.

Boofo 05-12-2008 02:59 AM

Ahh, ok, my bad. You are going to have do do a plugin for that to figure out the time portion of it, I think.

Mum 05-12-2008 03:05 AM

How would i go about that? Is there somewhere else i ask?

Boofo 05-12-2008 03:08 AM

No, you're in the right place.

First of all, what templates are you wanting to do this in?

Mum 05-12-2008 06:50 PM

I have used https://vborg.vbsupport.ru/showthrea...t=subscription to make my own page. And i ahve 2 items on the page, i want to do an if else for it.

if more than 5 posts in the last 24 hours show this

else

show that

akanevsky 05-13-2008 04:15 PM

You could use a plugin with the following code:

PHP Code:

$getposts $db->query_first("
    SELECT COUNT(*) as count 
    FROM " 
TABLE_PREFIX "post 
    WHERE userid = 
{$vbulletin->userinfo['userid']} 
    AND (" 
TIMENOW " - dateline) < 432000"
);
$show['something'] = ($getposts['count'] >= true false); 

Where 432000 is the number of seconds in 24 hours, and something can be replaced with anything you want, as long as it's a proper variable name. Which hook you choose depends on where it is to be used. Or, since you are using it in the "how to create your pages" hack, you can just place the code before $navbits = construct_navbits($navbits); in the php code.

And once you add the plugin (or the code into the page), you can use $show['something'] in your template.

Mum 05-13-2008 06:13 PM

The 'something' that i want to show is html code - how do i fix that? (sorry i am a noob at this side of things)

akanevsky 05-13-2008 06:23 PM

HTML Code:

<if condition="$show['something']">your html code</if>
Or, if you need alternate code if $show['something'] is false, use this:

HTML Code:

<if condition="$show['something']">your html code<else />alternate html code</if>


All times are GMT. The time now is 07:19 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
  • Page Generation 0.02056 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete