MyBB Community Forums
If empty... - 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 Development (https://community.mybb.com/forum-68.html)
+---- Thread: If empty... (/thread-205546.html)



If empty... - CezPlayer - 2016-11-01

When in MyBB Settings, setting "reminder_admin_text" is empty I want this:
if ($mybb->usergroup['cancp'])
 if($mybb->settings['reminder_enabled'] == 1)
if($mybb->settings['reminder_quantity'] == 1)
if(!empty($mybb->settings['reminder_admin_text'])) {
$reminder = '<table border="0" cellspacing="0" cellpadding="0" class="tborder">
<tr>
<td style="word-break: break-all;" class="thead"><p align="center">'.$mybb->settings['reminder_name'].'</p></td>
</tr>
<tr>
<td style="word-break: break-all; padding: 10px;" class="trow1"> <p align="center">EMPTY</p></td>
</table><br /><br />';
}
but word "EMPTY" is ever than, when this setting is filled.


RE: If empty... - dragonexpert - 2016-11-01

It is really ugly not using any braces for an IF statement in PHP. I think that is contriifbuting to your problem. Second, you can drop the !empty and just have that part be
if($mybb->settings['reminder_admin_text']) {
// Rest of your code
}



RE: If empty... - Matt - 2016-11-01

(2016-11-01, 01:07 PM)dragonexpert Wrote: It is really ugly not using any braces for an IF statement in PHP

This. Could also be combined into one condition:

if($mybb->usergroup['cancp'] && $mybb->settings['reminder_enabled'] == 1 && $mybb->settings['reminder_quantity'] == 1 && $mybb->settings['reminder_admin_text'])



RE: If empty... - CezPlayer - 2016-11-01

It's not work. I tried with:
		if ($mybb->usergroup['cancp'])
		if($mybb->settings['reminder_enabled'] == 1)
			if($mybb->settings['reminder_quantity'] == 3)
				if($mybb->settings['reminder_admin_text'])
		{
			$reminder = '
				<table border="0" cellspacing="0" cellpadding="0" class="tborder">
					<tr>
						<td style="word-break: break-all;" class="thead"><p align="center">'.$mybb->settings['reminder_name'].'</p></td>
					</tr>
					<tr>
	<td style="word-break: break-all; padding: 10px;" class="trow1"> <p align="center">'.$mybb->settings['reminder_admin_text'].'</p></td>
				</table><br /><br />
			<table border="0" cellspacing="0" cellpadding="0" class="tborder">
					<tr>
						<td style="word-break: break-all;" class="thead"><p align="center">'.$mybb->settings['reminder_name'].'</p></td>
					</tr>
					<tr>
	<td style="word-break: break-all; padding: 10px; border-bottom: 2px solid #E3E3E3" class="trow1"> <p align="center">'.$mybb->settings['reminder_text'].'</p></td>
	<tr>
	<td style="word-break: break-all; padding: 10px; border-bottom: 2px solid #E3E3E3" class="trow1"> <p align="center">'.$mybb->settings['reminder_text2'].'</p></td>
	</tr>
		<td style="word-break: break-all; padding: 10px;" class="trow1"> <p align="center">'.$mybb->settings['reminder_text3'].'</p></td>
				</table><br /><br />';
		}
EDIT: I'm sorry, I forgot about change quantity ;)

It's not working. Why?
 if($mybb->settings['reminder_enabled'] == 1)
            if($mybb->settings['reminder_quantity'] == 1)
While these circumstances will be agree this table still will be show.
I don't know, as bypass this without remove this settings.