Hello,
I'm trying to get a listing of the articles with a dropdown to filter them by categorie.
The listing is working except the filtering.
In Models, I have the principal model named 'articles' for the table '#__content' and conditions :
In Front list -> List Display -> table -> header code I have this code :
In Front List -> Settings I have 'articles.catid' in filters.
When I click on the button, the listing refresh but the data is not filtered.
Something is certainly missing, but I'm not a pro in CC neither in php.
Can someone help me please?
I'm trying to get a listing of the articles with a dropdown to filter them by categorie.
The listing is working except the filtering.
In Models, I have the principal model named 'articles' for the table '#__content' and conditions :
<?php
return array("articles.access"=>1);
?>
.
In Front list -> List Display -> table -> header code I have this code :
<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select(array('a.id','a.title'))
->from($db->quoteName('#__categories','a'))
->where($db->quoteName('a.parent_id').'=92');
$db->setQuery($query);
$categories=$db->loadAssocList();
$k=array_map(function($element){return $element['id'];},$categories);
$v=array_map(function($element){return $element['title'];},$categories);
$options=array_combine($k,$v);
$field = array (
'name' => 'fltr[articles][catid]', 'id' => '', 'options' => array ( ),
'empty' => '', 'values' => array ( ), 'label' => array ( 'text' => 'Activité', 'position' => 'left', ),
'sublabel' => '', 'multiple' => '0', 'size' => '', 'class' => '', 'title' => '', 'style' => '', 'params' => '', ':data-load-state' => '',
':data-tooltip' => '', 'type' => 'dropdown', 'container_id' => '0',);
$field["options"] = $options;
echo \GCore\Helpers\Html::formLine($field["name"], $field);
?>
<div class="form-group gcore-form-row" id="form-row-1"><div class="gcore-input gcore-display-table" id="fin-button">
<input name="button" id="button" type="submit" value="Valider" class="form-control A" style="" data-load-state="" /></div></div>
In Front List -> Settings I have 'articles.catid' in filters.
When I click on the button, the listing refresh but the data is not filtered.
Something is certainly missing, but I'm not a pro in CC neither in php.
Can someone help me please?