在Joomla中检测类别ID = 4并显示div

I would like to detect a certain category with ID=4 and then apply if/else to add div to display contents.

<?php 
    if (JRequest::getVar('view')=='categories' && JRequest::getVar('id')==4) { ?>
<?php } ?>

How do I achieve this? I want to show this if the article belongs to category 4 else show another div.

Imagining this two be the different div

<div class="category4">text here</div>
<div class="categoryxxx">text here</div>

Do note that <?php echo $this->item->catid;?> shows the correct Category ID. I would like to apply if and else statement using catid==9 or something. Just not good at PHP.

You can also put directly the html code, avoiding echo. It may useful especially when html code is sizeable.

<?php if ($this->item->catid == 4): ?>

<div class="category4">text here</div>
<!--- any other html code --->

<?php else: ?>

<div class="categoryxxx">text here</div>
<!--- any other html code --->

<?php endif; ?>

Hey I got it working :)

<?php
if ($this->item->catid == 9) { 
    echo "yes, it exists"; 
    } 
    else { 
    echo "no, it don't exist"; 
    }
?>