Click here to Skip to main content
14,732,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a category page which lists all articles belongs to that category in joomla.

I have made a custom content plugin, which is for setting a custom field while creating articles of any type, Now i can see/access in "OnContentPrepare" method the custom value which i saved during article creation.

Now i want my plugin to hide/remove article which have value 1 for custom field from frontend thats it.

But this shouldnt affect any backend values like publish, title, content e.t.c. Just "display:none" of CSS.

below is the code of my plugin:

defined ( '_JEXEC' ) or die ( 'Restricted access' );
class plgContentDtStatus extends JPlugin
{
protected $autoloadLanguage = true;
public function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
switch($option) {
case 'com_content':
if ($app->isAdmin()) {
JForm::addFormPath(__DIR__ . '/forms');
//Show specific forms based on categories
$form->loadFile('content', false);
}
return true;
}

return true;
}

public function onContentPrepare($context, &$article, &$params, $page = 0)
{

if(isset($article->attribs) && !empty($article->attribs)){
$attr=json_decode($article->attribs);
/* After this line i can access the custom field value */
}

if(isset($attr->is_done) && $attr->is_done){

//-------------------------
$article->images=0;
$article->published=0;
$tmp=json_decode($params->__toString());
foreach($tmp as $key=>$val)
{
$params->set($key,0);
$article->text='';
}
/* Right now i am trying above code to hide articles not working for all templates. i want to place a class or inline css to hide whole div of article, or is there any way to skip the article and move to next one */
//-------------------------
}

return true;
}

}

Please suggest, Thanks in advance.

What I have tried:

i have placed my code what i have tried yet.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900