donglin1192 2017-04-14 12:06
浏览 56
已采纳

在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.

  • 写回答

2条回答 默认 最新

  • dpo60833 2017-04-14 17:41
    关注

    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; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测