简体   繁体   English

如果当前文章类别ID为Joomla,则显示内容

[英]Joomla show content if current article category id is

i am using joomla 2.5 and i want to show some special text only in those articles which belongs to category id 11. 我正在使用joomla 2.5,并且只想在属于类别ID 11的那些文章中显示一些特殊文本。

to get category id i tried: 得到我尝试过的类别ID:

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

to check if current category id is 11 and then show special text i used: 检查当前类别ID是否为11,然后显示我使用的特殊文本:

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

but it is not working :( text can be seen in all categories. 但它不起作用:(可以在所有类别中看到文本。

Your if statement doesn't look right... try this: 您的if语句看起来不正确...请尝试以下操作:

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

See "Alternative syntax for control structures" on php.net 参见php.net上的“控制结构的替代语法”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM