Hide the <li tab if the condition is met

I have a foreach view that checks if the user has an image or not. If the user does not have an image, I want to hide the tab <li>that displays the image.

Inside mine else, how can I say for this user to hide tab 2?

I tried to use echo 'id="tabHeader_2" style:"visibility:hidden"; but it does not work. I need a link to this tab2, right?

<div id="picture<?php echo $i ?>" style="display: none;">
<?php
      $picture = $user->pic;
      if(isset($picture))
      {
         // show picture.           
      }
      else
      {
        // hide tab2
      }                   
  ?>    
 </div>             

Then a list of tabs:

 <div class="profiles">
     <div id="tabContainer">
         <div class="tabs">
            <ul>
              <li id="tabHeader_1"> Profile </li>
              <li id="tabHeader_2"> Picture </li>
             </ul>
         </div>
         <div id="tabsContent">
              <div class="tabpage" id="tabpage_1"></div>
              <div class="tabpage" id="tabpage_2"></div>
         </div>
         <script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/tabs.js"></script>
     </div>
 </div>

The image of the page is as follows:

enter image description here

+4
source share
2 answers

100% , isset(), , , ​​ 100% . empty() is_file(), , , .

<!-- This display: none seems strange if you are going to show the wrapped elements -->
<div id="picture<?php echo $i ?>" style="display: none;">
<?php

      $picture = $user->pic;
      if(!empty($picture)) {
         // show picture.           
      }
      else {
        // hide tab2
      }                   
  ?>    
 </div>

, , .

0

: -

<div class="tabs">
  <ul>
      <?php
      $i = 1;
      foreach($yourarray as $key => $value){
           if(isset($value) && $value != '')
           ?>
               <li id="tabProfileHeader<?php echo $i;?>"> Profile </li>
               <li id="tabPictureHeader<?php echo $i;?>"> Picture </li>
            <?php
         $i++;
         }
         ?>
     </ul>
</div>
-1

All Articles