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:

+4
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