MyBB Community Forums

Full Version: Using Template parts outside of their originally defined template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Sweet, thanks a lot, this project is already balancing on it's budget, so any time savers are greatly appreciated. If I manage to come up with an answer, I'll post it here in case anyone else needs to do this in future.
Sudo Wrote:<?php echo date("jS F, Y", ($mybb->user['lastactive'])); ?>

That is correct for the current connected user (yes, if it is a guest it wouldn't work). For posts you need:
<?php echo date("jS F, Y", $post['lastactive']); ?>

IMO you should use a plugin for anything that requires you to use the PHP In Templates plugin, here is the Templates Conditional plugin code:
<?=my_date('jS F, Y', $post['lastactive'])?>

You should probably do a check to know if the lastactive array key exists in case the user doesn't exists (i.e: the post is made by a guest).
<if intval($post['lastactive']) > 0 then><?=my_date('jS F, Y', $post['lastactive'])?></if>
(2012-11-12, 06:45 PM)Omar G. Wrote: [ -> ]
Sudo Wrote:<?php echo date("jS F, Y", ($mybb->user['lastactive'])); ?>

That is correct for the current connected user (yes, if it is a guest it wouldn't work). For posts you need:
<?php echo date("jS F, Y", $post['lastactive']); ?>

IMO you should use a plugin for anything that requires you to use the PHP In Templates plugin, here is the Templates Conditional plugin code:
<?=my_date('jS F, Y', $post['lastactive'])?>

You should probably do a check to know if the lastactive array key exists in case the user doesn't exists (i.e: the post is made by a guest).
<if intval($post['lastactive']) > 0 then><?=my_date('jS F, Y', $post['lastactive'])?></if>

Ah thank you very much, haven't used any of MyBBs PHP side before, so this is all learning. Thanks again for your help.
Pages: 1 2