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 - Lo. - 2009-08-31

Make a database backup, and a file back move to a new directory and try. So your users don't go offline.


RE: PHP in Templates and Template Conditionals - Yumi - 2009-08-31

Firstly, try it on the default theme with unmodified templates and see if it works there.


RE: PHP in Templates and Template Conditionals - Joshee - 2009-09-30

How can I use this for adding external templates?
For example, if im editing a template called 'myTemplate' and I make another template called 'myTemplate2', how could I get 'myTemplate2' to display in 'myTemplate?
Hope that makes sense...


RE: PHP in Templates and Template Conditionals - xScopex - 2009-11-29

(2008-11-01, 07:06 AM)Yumi Wrote: It depends on where you put it, but you could try something like this:
<if $GLOBALS['mybb']->user['usergroup'] == 4 then> stuff for usergroup 4</if>

Is there a way to make this work for more than one user group? I've been trying but I can't seem to get it to work with more than one user group.


RE: PHP in Templates and Template Conditionals - Yumi - 2009-11-29

<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>

or

<if in_array($GLOBALS['mybb']->user['usergroup'], array(4,5,6)) then> stuff for usergroup 4,5,6</if>



RE: PHP in Templates and Template Conditionals - Schmarvin - 2009-11-29

Awesome plugin, thanks for this!


RE: PHP in Templates and Template Conditionals - xScopex - 2009-12-01

(2009-11-29, 01:56 AM)Yumi Wrote:
<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>

or

<if in_array($GLOBALS['mybb']->user['usergroup'], array(4,5,6)) then> stuff for usergroup 4,5,6</if>

Thank you much! It works perfectly. Smile


RE: PHP in Templates and Template Conditionals - Joey_Pham423 - 2009-12-08

I have tried to change the forumdisplay_thread template, which likes this:
From
	<td align="center" class="{$bgcolor}" width="2%">{$icon}</td>
To
	<td align="center" class="{$bgcolor}" width="2%"><if><img src="images/icons/smile.gif"> <else />{$icon}</if></td>

and it didn't work, so how can I you the php language to make it works?


RE: PHP in Templates and Template Conditionals - Yumi - 2009-12-08

I really don't know what you're trying to do. For one, you don't have an if condition, so it doesn't actually make any sense.


RE: PHP in Templates and Template Conditionals - Joey_Pham423 - 2009-12-09

sorry about that, but what I am trying to do is to make a default thread icon for each post in the forumdisplay, because when we post a thread, if we don't chose a post icon for it, then there will be no icon.

I think you better look at my demo below, hope that can make sense to you. I need the blue section have a default icon, not just blank like that.