View Full Version : 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, 03:18 AM
Try ths:
<if condition="$post['postcount'] > '5'">
do this
<else />
do that
</if>
or
<if condition="$post['postcount'] > '5'">
do this
</if>
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, 03: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.
How would i go about that? Is there somewhere else i ask?
Boofo
05-12-2008, 04:08 AM
No, you're in the right place.
First of all, what templates are you wanting to do this in?
I have used https://vborg.vbsupport.ru/showthread.php?t=62164&highlight=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, 05:15 PM
You could use a plugin with the following 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'] >= 5 ? 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.
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, 07:23 PM
<if condition="$show['something']">your html code</if>
Or, if you need alternate code if $show['something'] is false, use this:
<if condition="$show['something']">your html code<else />alternate html code</if>
Thank you so much - that worked perfectly!
Is there any way that i can exclude a usergroup from that? Ie if they are in X group then they are fine to go in there regardless (i want to turn it off for staff)
veenuisthebest
05-14-2008, 06:27 PM
If Viewer is in the Following Usergroups Array. Enter the Usergroup Number(s) Separated by a Comma
<if condition="is_member_of($vbulletin->userinfo, 1, 2, 3)"></if>
Wrap it in this conditional the ones you want to include !!
akanevsky
05-14-2008, 07:48 PM
// settings
$usergroupids = array(1,2,3);
// decision clause
$show['something'] = false;
if (!is_member_of($vbulletin->userinfo, $usergroupids))
{
$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'] >= 5 ? true : false);
}
Sweeks
04-19-2009, 09:01 PM
Will this work for this:
What I want is to display some HTML when a user has less than X amount of posts, any ideas on how to achieve this?
Thanks very much :)
--------------- Added 1240179092 at 1240179092 ---------------
I have tried this:
<if condition="$post['postcount'] < '25'">
<div>
<p>THIS WILL SHOW IF YOU HAVE UNDER 25 POSTS
THIS IS A TEST IGNORE ME!!!!!!</p></div>
<else />
<div><p>THIS WILL SHOW IF YOU HAVE OVER 25 POSTS THIS IS A TEST IGNORE ME!!!!</p></div>
</if> But no such luck.
--------------- Added 1240179940 at 1240179940 ---------------
I have also tried this with no luck :(
<if condition="$bbuserinfo[maxposts]==25">
<p>This is a test ignore me</p>
<else />
<p>Testing</p>
</if>
________
Class Action Settlement (http://classactionsettlements.org/)
EnIgMa1234
04-19-2009, 10:49 PM
Will this work for this:
What I want is to display some HTML when a user has less than X amount of posts, any ideas on how to achieve this?
Thanks very much :)
--------------- Added 1240179092 at 1240179092 ---------------
I have tried this:
<if condition="$post['postcount'] < '25'">
<div>
<p>THIS WILL SHOW IF YOU HAVE UNDER 25 POSTS
THIS IS A TEST IGNORE ME!!!!!!</p></div>
<else />
<div><p>THIS WILL SHOW IF YOU HAVE OVER 25 POSTS THIS IS A TEST IGNORE ME!!!!</p></div>
</if> But no such luck.
--------------- Added 1240179940 at 1240179940 ---------------
I have also tried this with no luck :(
<if condition="$bbuserinfo[maxposts]==25">
<p>This is a test ignore me</p>
<else />
<p>Testing</p>
</if>
What template do you want it in?
Sweeks
04-20-2009, 08:09 AM
User CP :)
________
Bondage vid (http://www.++++tube.com/categories/14/bondage/videos/1)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.