MyBB Community Forums
PHP in Templates and Template Conditionals - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Support (https://community.mybb.com/forum-72.html)
+---- Thread: PHP in Templates and Template Conditionals (/thread-31860.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


RE: PHP in Templates and Template Conditionals - gokufg - 2010-03-24

Hi Yumi, thanks a lot!!!

And if I wanna check the specific forum also? For example I want show "some staff1" in a forum fid=1 and "some staff2" in a forum fid=2. Is it possible?

Thanks a lot!!


RE: PHP in Templates and Template Conditionals - Yumi - 2010-03-24

<if $GLOBALS['forum']['fid'] == 1 then>
blah
</if>

Won't necessarily work everywhere.


RE: PHP in Templates and Template Conditionals - FBI - 2010-03-24

I remember SMF did perfectly.
When a moderator post on forum they moderated, their mod usergroup will display.
But if his/her post on another forum, usergroup back to normal (general member is displayed).

Any idea Yumi? Smile


RE: PHP in Templates and Template Conditionals - Yumi - 2010-03-24

<if is_moderator($post['fid'], '', $post['uid']) then>
I am a moderator of this forum
</if>


RE: PHP in Templates and Template Conditionals - FBI - 2010-03-24

Damn nice Yumi Big Grin
Work like a charm
Adding link for direct PM existing Moderator..
On postbit_author_user

<if is_moderator($post['fid'], '', $post['uid']) then>
<font color="red" size="-3">I am moderator <a href="private.php?action=send&uid={$post['uid']}"><u>here</u></a>.</font>
</if>



RE: PHP in Templates and Template Conditionals - gokufg - 2010-03-24

(2010-03-23, 11:10 PM)Yumi Wrote: Maybe try something like this in the postbit template:
<?php
static $first_done = false;
if(!$first_done) {
$first_done = true;
echo 'Stuff in first post';
}
?>

This code put 'Stuff in first post' in all posts....Sad


(2010-03-24, 08:56 AM)Yumi Wrote: <if $GLOBALS['forum']['fid'] == 1 then>
blah
</if>

It doesn't work Sad


RE: PHP in Templates and Template Conditionals - FBI - 2010-03-24

Hi GokuFG,

Try this, and place it on postbit templates
<center><?php
if ($postcounter == 2){
echo 'Banner Place Postbit';
}
?></center>

display some stuff like banner or something, right after first post.
but, this is only first page Smile
for all pages, should be add other conditional base on MyBB "posts per page" setting.
Maybe Yumi can help for additional codes


RE: PHP in Templates and Template Conditionals - Yumi - 2010-03-25

<if ($GLOBALS['forum']['fid'] == 1 || $GLOBALS['foruminfo']['fid'] == 1) && !$GLOBALS['my_first_post'] && ($GLOBALS['my_first_post'] = true) then>
first post in forum id 1
</if>



RE: PHP in Templates and Template Conditionals - gokufg - 2010-03-25

the code

<if !$GLOBALS['my_first_post'] && ($GLOBALS['my_first_post'] = true) then>
first post in forum id 1
</if>

It's ok and works

EDIT

I tried to insert in forum template

<if ($GLOBALS['forum']['fid'] == 36 || $GLOBALS['foruminfo']['fid'] == 36) then>
first post in forum id 36
</if>


and the "first post in forum id 36" showed in that forum... But I'd like show "first post in forum id 36" in all threads of forum 36 and i all subforums. Do you understand?


RE: PHP in Templates and Template Conditionals - Yumi - 2010-03-26

(2010-03-25, 10:31 AM)gokufg Wrote: and the "first post in forum id 36" showed in that forum... But I'd like show "first post in forum id 36" in all threads of forum 36 and i all subforums. Do you understand?
Read up on PHP and how it evaluates conditionals. I'm only going to help with simple requirements, but for more complex things, you really should spend the few minutes to learn how it really works under the hood.