Php 在Joomla中检测类别ID=4并显示div
我想检测ID=4的特定类别,然后应用if/else将div添加到显示内容中Php 在Joomla中检测类别ID=4并显示div,php,joomla,joomla2.5,joomla3.0,Php,Joomla,Joomla2.5,Joomla3.0,我想检测ID=4的特定类别,然后应用if/else将div添加到显示内容中 <?php if (JRequest::getVar('view')=='categories' && JRequest::getVar('id')==4) { ?> <?php } ?> 我如何做到这一点? 如果文章属于第4类,我想显示这个,否则显示另一个div 想象这两个是不同的部门 <div class="category4">text here<
<?php
if (JRequest::getVar('view')=='categories' && JRequest::getVar('id')==4) { ?>
<?php } ?>
我如何做到这一点?
如果文章属于第4类,我想显示这个,否则显示另一个div
想象这两个是不同的部门
<div class="category4">text here</div>
<div class="categoryxxx">text here</div>
请注意,它显示了正确的类别ID。我想使用catid==9或其他什么应用if和else语句。只是不擅长PHP。嘿,我已经开始工作了:
<?php
if ($this->item->catid == 9) {
echo "yes, it exists";
}
else {
echo "no, it don't exist";
}
?>
嘿,我成功了:
<?php
if ($this->item->catid == 9) {
echo "yes, it exists";
}
else {
echo "no, it don't exist";
}
?>
您还可以直接放入html代码,避免回声。它可能特别有用,尤其是当html代码相当大时
<?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; ?>
您还可以直接放入html代码,避免回声。它可能特别有用,尤其是当html代码相当大时
<?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; ?>