Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Multiple Cross-References in a Table 12 Dec 2016 13:43 #14836

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
Hi all,

I have designed a component Project witch included 2 XRef in the main table.


  • A Conference can be managed by one or many Intervenants,
  • A Conference cover one or many Themes

I 've some questions about that because it seems that the Builder do not handle the second Cross-Reference.
- Is that true or it comes from my table design ?
- Do I have to code the second Xref manualy ?
- Has someone experimented something like that ?

Thanks for your share,
Marc

Please Log in or Create an account to join the conversation.

Last edit: by liubov.

Multiple Cross-References in a Table 13 Dec 2016 22:36 #14847

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
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>

Please Log in or Create an account to join the conversation.

Last edit: by liubov.

[closed]Multiple Cross-References in a Table 22 Dec 2016 10:27 #14863

  • liubov
  • liubov's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
  • (=) 10 mn and it's ready!
  • Posts: 279
  • Thank you received: 36
hi,
I don't know if it was cache troubles, or a feature update, but I now see the 2 XRef of my main Table to drag proper fields in my layouts.
I just had to use F5 (refresh page) to see the Builder buld the second XRef ...

Please Log in or Create an account to join the conversation.

Last edit: by liubov.
  • Page:
  • 1
Time to create page: 0.058 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started