Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Template Conditionals | If Under X Posts Show Div
DrBaja Offline
Junior Member
**
Posts: 1
Joined: Dec 2017
Post: #1
Template Conditionals | If Under X Posts Show Div
Hey,

I'd like to make a template code say If User has less than 10 posts then set .underPostNotification visible to inline else then set to none.

Basically, I'd like to show users a message if they have under 10 posts (to warn them about spamming is not tolerated and remind them of posting rules)

I haven't seen any in-depth tutorials on how to use Template Conditionals.
I have knowledge of CSS, JS, HTML, and PHP. I'm also familiar with how the MyBB template system works.

If someone could point me to an in-depth tutorial or give me some tips on how to do this that would be awesome!

Here is a quick code I whipped up from some posts I've seen.

PHP Code:
 <if $mybb->user['postnum'] >= 9 then>
// Not sure what to put here but it should set the Visble to Inline (Visible)
<else>
// Not sure what to put here but it should set the Visble to None (Disapear)
</if>


Thanks,
DrBaja

(This post was last modified: 12-12-2017 01:38 PM by DrBaja.)
12-12-2017 01:31 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,325
Joined: Mar 2010
Post: #2
RE: Template Conditionals | If Under X Posts Show Div
There are some ways to do it, depends on how the layout.
But the most important thing is your conditional above.

Simple example:

Code:
<if $mybb->user['postnum'] < 10 then>
	<div class="underPostNotification">Message here</div>
</if>


The div and the massage will be displayed only for the users who have posts less than 10.


12-16-2017 02:48 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: