“包含类别”的代码是什么


What will be the code for Include Category

下面的joomla插件代码是为"从joomla类别中排除类别"选择的,我想知道如何使其包含类别。

class plgContentExtcustomhtml extends JPlugin {
public function onContentAfterDisplay($context, &$row, &$params, $page=0)   {
if($context == 'com_content.article') {
//exclude
$ext_exclude_categories     = $this->params->get('ext_exclude_categories', 0);
$ext_exclude_articles       = $this->params->get('ext_exclude_articles', '');
//exclude category
if(!empty($ext_exclude_categories) AND strlen(array_search($row->catid, $ext_exclude_categories))){
return false;
}

上面的代码来自一个插件。只有当当前页面要显示一篇文章,并且该类别不在排除的类别中时,它才有效。

如果你想改变逻辑,迫使它只适用于被排除的类别,那么我认为你需要改变:

//exclude category
if(!empty($ext_exclude_categories) AND strlen(array_search($row->catid, $ext_exclude_categories))){
return false;
}

到此:

//exclude category
if(empty($ext_exclude_categories) OR !strlen(array_search($row->catid, $ext_exclude_categories))){
return false;
}

首先备份您的代码。:-)