MyBB Community Forums

Full Version: Template Conditionals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm quite new to MyBB and I must say great job, think I've found a forum for life once I work out how everything works Smile

Just one thing I've come across I would like some help with. I'm editing the template a bit and I would like to add several scenarios depending weather the user is logged in or not, an admin or a moderator.

Basically I want to know how I would go about this, I've looked about the forums and only found things in which I have to edit the gobal.php file, any alternatives to doing this?

Thanks in advance
Ben
Have you installed it yet? If so just go to AdminCP > Templates &Style > Templates > {theme} > {pick your template} > {edit that template}

I hope this helped.
Yeah, I've done that and I'm editing the header/footer templates etc just fine its all nicely laid out. But what I want to do is have a section which shows different text depending on the status of the user.

For example in PHP it would be:

if ($user['[id'] > 0)
{
echo "you are logged in";
else
{
echo "you are not logged in";

just wondering if there was a way of doing that in side of templates, and if not how would I go about doing this?
Generally, you'll need to write a plugin for something like this - MyBB's templates don't contain logic (ie, we separate HTML from the logic).

But I do have a plugin which can add template conditionals if that's what you want: http://community.mybboard.net/thread-31860.html
Thank you, just downloaded and installed your plug-in, wondering if you could just quickly tell me how I would go about doing if the user is logged in, and weather they have admin or mod powers?
You'd put in something like this into your template:
<if $mybb->user['uid'] then>
User is logged in
<else>
User not logged in
</if>



<if $mybb->usergroup['cancp']==1 then>
User is admin
<else>
User not admin
</if>