News:

Wondering if this will always be free?  See why free is better.

Main Menu

1.1.14 Coding Question

Started by Biology Forums, August 15, 2011, 06:21:21 PM

Previous topic - Next topic

Biology Forums

I'm trying to create a custom code, but I need help condensing it.

if($context['user']['is_logged'] && ($board['id'] == 2) && empty($board['tidy_children']))

echo'

<ul style="padding:0 0.5em 0 0.5em; list-style: none; font-size: x-small;
  font-weight: bold;"><li><img src="', $settings['images_url'], '/', ($child['new'] ? 'on' : 'off'), '.gif" width="12" height="12" alt="">&nbsp; <a href="', $scripturl . '?action=post;board=',  $board['id'] ,'">Add News Article</a></li>
</ul>

';

if($context['user']['is_logged'] && ($board['id'] == 3) && empty($board['tidy_children']))

echo'

<ul style="padding:0 0.5em 0 0.5em; list-style: none; font-size: x-small;
  font-weight: bold;"><li><img src="', $settings['images_url'], '/', ($child['new'] ? 'on' : 'off'), '.gif" width="12" height="12" alt="">&nbsp; <a href="', $scripturl . '?action=post;board=',  $board['id'] ,'">New Topic</a></li>
</ul>

';

if($context['user']['is_logged'] && ($board['id'] == 4) && empty($board['tidy_children']))

echo'

<ul style="padding:0 0.5em 0 0.5em; list-style: none; font-size: x-small;
  font-weight: bold;"><li><img src="', $settings['images_url'], '/', ($child['new'] ? 'on' : 'off'), '.gif" width="12" height="12" alt="">&nbsp; <a href="', $scripturl . '?action=post;board=',  $board['id'] ,'">New Topic</a></li>
</ul>

';



For board 2, I want it to say: Add News Article.

For board 3, 4, 5, 6, and 7, I want it to say: New Topic. However, I do not want to continue writing this code until 7:

if($context['user']['is_logged'] && ($board['id'] == #) && empty($board['tidy_children']))
            
            echo'
            
                        <ul style="padding:0 0.5em 0 0.5em; list-style: none; font-size: x-small;
  font-weight: bold;"><li><img src="', $settings['images_url'], '/', ($child['new'] ? 'on' : 'off'), '.gif" width="12" height="12" alt="">&nbsp; <a href="', $scripturl . '?action=post;board=',  $board['id'] ,'">New Topic</a></li>
                        </ul>

                     ';


What should I do?

IchBin™


$boardArray
= array(3,4,5,6,7);

if(
$context['user']['is_logged'] && (in_array($board['id'], $boardArray)) && empty($board['tidy_children']))
IchBin™        TinyPortal

Biology Forums

Quote from: IchBin™ on August 15, 2011, 10:58:50 PM

$boardArray
= array(3,4,5,6,7);

if(
$context['user']['is_logged'] && (in_array($board['id'], $boardArray)) && empty($board['tidy_children']))


Thanks I'll try that!

Advertisement: