MyBB Hacks

Full Version: Will nested IF statements work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I'm using this in usercp_nav to display two different menus depending on which page you are viewing. The if statements for the CSS classes and inbox unread count were working before being nested in another IF -- is this a problem? Are nested IF disallowed?

Code:
<!-- User CP Menu -->

<if THIS_SCRIPT == "usercp.php" then>
<div class="cp_menu"><a href="/usercp.php"<if $mybb->input['action'] == '' ||  $mybb->input['action'] == 'changename' ||  $mybb->input['action'] == 'editsig' ||  $mybb->input['action'] == 'email'  || $mybb->input['action'] == 'password' then> class="current"</if>>Profile & Settings</a> <a href="/usercp.php?action=editlists"<if $mybb->input['action'] == 'editlists' then> class="current"</if>>Friends and Foes</a> <a href="/usercp.php?action=drafts"<if $mybb->input['action'] == 'drafts' then> class="current"</if>>Drafts</a> <a href="/usercp.php?action=subscriptions"<if $mybb->input['action'] == 'subscriptions' then> class="current"</if>>Following</a> <a href="/User-{$mybb->user['username']}" style="float: right;">Go to profile ➜</a></div></if>

<!-- Private Messages Menu -->

<if THIS_SCRIPT == "private.php" then>

<td valign="top" style="width: 200px; float: left; margin-right: 20px;">
<table border="0" cellspacing="0" cellpadding="0" class="insetbox messagenav" style="margin-bottom: 13px;">
	<tr>
		<td style="padding: 0px;">

<a href="/private.php?action=send" class="button bigbutton" style="display: block;">New Message</a><br />

<if $mybb->user['pms_unread'] == 0 then>
<a href="/private.php?fid=1" class="biglink <if $folder == 1 then>current</if>" style="display: block;">Inbox</a>

<else>
<a href="/private.php?fid=1" class="biglink <if $folder == 1 then>current</if>" style="display: block; font-weight: bold;">Inbox ({$lang->welcome_pms_usage})</a>
</if>

<a href="/private.php?fid=2" class="biglink <if $folder == 2 then>current</if>" style="display: block;">Sent</a>
<a href="/private.php?fid=3" class="biglink <if $folder == 3 then>current</if>" style="display: block;">Drafts</a>
<a href="/private.php?fid=4" class="biglink <if $folder == 4 then>current</if>" style="display: block;">Trash</a>
<br />
<div class="smalltext">
<a href="/private.php?action=tracking" style="display: block;">Track Messages</a>
<a href="/private.php?action=export" style="display: block;">Download Messages</a>
<a href="/private.php?action=empty" style="display: block;">Empty Folders</a>
</div>

</td></tr>

</table>
</td>
</if>

Do you mean that the 'current' class in private.php page doesn't work?
Correct. Was working before I put it within another If.
Try using $mybb->input['fid'] ?
That works, thanks!
How to show "current" if there is no input (e.g. just private.php?) this was working in the old code but not in the new one.
Depends on the input. If it is fid only, you can try using something like

Code:
<if !$mybb->input['fid'] then>current</if>

If you have too many conditionals there, maybe it is better if you try to simplify it (if there is a chance to do that)?

Nope, this doesn't work either, since it sets it as Current on any page where you input. I basically want it to show as current when there is NO input, simply private.php landing page. It worked in the original before I wrapped it in an if ...
Fixed it with this:

Code:
<if $mybb->input['fid'] == '' || $mybb->input['fid'] == 1 then>current</if>


Thanks for your help!

Ahh, but this doesn't work if you are on pages with other actions, like read, export, etc. ... inbox will still be highlighted.

I just need a way to say "if this is index.php with no inputs or actions". For now, I'll just change header link to address fid.
Pages: 1 2
Reference URL's