OK, I got it !
Xref (Pivot Table) and Pivots Filters are just awesome ! exceptionnals features ...
I have played with a lot today
Easy to implement mutiple Xref to the main Table.
- 1 - add the new Relation (FK) you want to associate in the xml definition of the main table.
admin/models/forms/conference.xml
<field name="themes"
alias="id"
label="JDPROGRAM_FIELD_LES_THEMES"
filter="array"
type="relation"
multiple="true"
labelKey="nom"/>
- 2 - add this new Relation into the view
admin/views/conferences/view.html.php
// Load relations in the object
$model->loadRelations('intervenants');
$model->loadRelations('themes');
- 3 - add the new PivotModel
admin/models/conferences.php
$this->belongsToMany('themes', // name
'themes', // foreignModelClass
'id', // localKey
'id', // foreignKey,
'coverfields', // pivotModelClass,
'conference_id', // pivotLocalKey
'theme_id', // pivotForeignKey
array('logo', 'nom') // selectFields
);
- 4 - add the new cells in the collection
admin/views/conferences/tmpl/default_grid.php
// Column title
<th style="text-align:left">
<?php echo JText::_("JDPROGRAM_FIELD_THEMES"); ?>
</th>
...
// datas displaying images ...
<td style="text-align:left">
<?php
if (isset($row->themes))
foreach($row->themes as $rel):
echo JDom::_('html.fly.file', array(
'width' => '38',
'height' => '38',
'dataObject' => $rel,
'dataKey' => 'logo',
'indirect' => false,
'root' => '[DIR_THEMES_LOGO]'
));
endforeach; ?>
</td>
or
// datas displaying badge name ...
<td style="text-align:left">
<?php
if (isset($row->themes))
foreach($row->themes as $rel):?>
<div class="badge">
<?php echo($rel->nom); ?>
</div>
<?php endforeach; ?>
</td>