【问题标题】:Joomla show content if current article category id is如果当前文章类别 ID 为,Joomla 显示内容
【发布时间】:2013-04-02 17:40:56
【问题描述】:

我正在使用 joomla 2.5,我只想在属于类别 id 11 的文章中显示一些特殊文本。

我尝试获取类别 ID:

<?php $catid = JRequest::getInt('catid'); echo $catid; ?>

检查当前类别 id 是否为 11,然后显示我使用的特殊文本:

<?php $catid = JRequest::getInt('catid'); if ($catid == 11) {?>SPECIAL TEXT<?php } ?>

但它不起作用:(所有类别中都可以看到文本。

【问题讨论】:

    标签: php joomla


    【解决方案1】:

    您的if 语句看起来不正确...试试这个:

    <?php $catid = JRequest::getInt('catid'); if ($catid == 11) : ?>SPECIAL TEXT<?php endif; ?>
    

    "Alternative syntax for control structures" on php.net

    【讨论】:

    • thanx,不幸的是,即使当前文章类别 ID 为 11,特殊文本也是不可见的。似乎我们需要 joomla 专家 :) 我的代码有问题。
    • 对不起,是我的错,我使用了错误的类别 ID,现在一切正常。
    • SPECIAL TEXT 也在工作,我的错误是在类别 id :)
    猜你喜欢
    • 1970-01-01
    • 2015-09-15
    • 1970-01-01
    • 2013-08-15
    • 2014-12-24
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    相关资源
    最近更新 更多