MyBB Community Forums

Full Version: PHP in Templates and Template Conditionals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
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!!
<if $GLOBALS['forum']['fid'] == 1 then>
blah
</if>

Won't necessarily work everywhere.
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
<if is_moderator($post['fid'], '', $post['uid']) then>
I am a moderator of this forum
</if>
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>
(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
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
<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>
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?
(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.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22