Table join relation : one to many

Status
Not open for further replies.

piri314

Member
Hi,

When I make a table relation from one to another table, exemple one "organisation" could have many "contact_persons", the form works very well, but in the table view if I have 4 persons, the organisation is repeated 4 times.

How to show in the TableView only one time the "Organisation" ?

Thanks

PIRINA
 
Hi Rob,

The modified templates doesn' t work for me

Parse error: parse error, unexpected $end in C:\Program Files\EasyPHP 2.0b1\www\components\com_fabrik\views\table\tmpl\contacts\template.php on line 79

(I renamed my 2 tables and made copy/paste of your exemple, but without any succes).
 
<?php /**
* @package fabrik
* @version 1.0.4
* @Copyright (C) Rob Clayburn
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
/* MOS Intruder Alerts */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>

<h1><?php echo $this->table->label;?></h1>
<div><?php echo $this->table->intro;?></div>
<form action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikTable">
<?php if($this->showAdd){?>
<span class="pagenav">
<a href="<?php echo $this->addRecordLink;?>"><?php echo _ADD_RECORD;?></a>
</span>
<?php }?>
<?php if($this->showCSV){?>
<span class="pagenav">
<a href="<?php echo $this->csvLink;?>"><?php echo _EXPORT_TO_CSV;?></a>
</span>
<?php }?>
<?php if($this->showRSS){?>
<span class="pagenav">
<a href="<?php echo $this->rsslink;?>"><?php echo _SUBSCRIBE_RSS;?></a>
</span>
<?php }?>
<?php if($this->showFilters){?>
<table class="filtertable">
<tr>
<th colspan="2" style="text-align:left"><?php echo _SEARCH;?>:</th>
</tr>
<?php foreach($this->filters as $filter){?>
<tr>
<td><?php echo $filter->label;?></td>
<td style="text-align:right;"><?php echo $filter->element;?></td>
</tr>
<?php } ?>
<?php if($this->filter_action != 'onchange') {?>
<tr>
<td colspan="2" style="text-align:right;">
<input type="button" class="button" value="<?php echo _GO;?>" name="filter" />
</td>
</tr>
<?php }?>
</table>
<?php }?> <br style="clear:both;" />
<br />
<?php if(count($this->rows) == 0){?>
<div class="emptyDataMessage"><?php echo $this->emptyDataMessage;;?></div>
<?php }else{
$firstRecord = $group[0];
$companyName = $firstRecord->jos_annuaire___structure; //name of the table
echo "<p>Company:$companyName</p>";
foreach($this->rows as $group){?>
<table class="fabrikTable">
<tr><th>Structure</th></tr>
<?php
$c = 0;
foreach($group as $row){
?>
<tr class="oddrow<?php echo $c;?>">
<td><?php echo($row->jos_annuaire_noms___Nom);?></td>//name of the joined table
</tr>
<?php $c = 1-$c;
?>
</table>
<?php }
if( $this->canDelete ){?>
<label><input type="checkbox" id="table_<?php echo $this->table->id;?>_checkAll" /><?php echo _CHECK_ALL;?></label>
<?php
}
print_r($this->hiddenFields);?>
<?php echo $this->nav;
echo $this->deleteButton;
?>
</form>

*******

Thanks
PIRINA
 
Pirina LATCHKOVA said:
<?php /**
* @package fabrik
* @version 1.0.4
* @Copyright (C) Rob Clayburn
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/
/* MOS Intruder Alerts */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>

<h1><?php echo $this->table->label;?></h1>
<div><?php echo $this->table->intro;?></div>
<form action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikTable">
<?php if($this->showAdd){?>
<span class="pagenav">
<a href="<?php echo $this->addRecordLink;?>"><?php echo _ADD_RECORD;?></a>
</span>
<?php }?>
<?php if($this->showCSV){?>
<span class="pagenav">
<a href="<?php echo $this->csvLink;?>"><?php echo _EXPORT_TO_CSV;?></a>
</span>
<?php }?>
<?php if($this->showRSS){?>
<span class="pagenav">
<a href="<?php echo $this->rsslink;?>"><?php echo _SUBSCRIBE_RSS;?></a>
</span>
<?php }?>
<?php if($this->showFilters){?>
<table class="filtertable">
<tr>
<th colspan="2" style="text-align:left"><?php echo _SEARCH;?>:</th>
</tr>
<?php foreach($this->filters as $filter){?>
<tr>
<td><?php echo $filter->label;?></td>
<td style="text-align:right;"><?php echo $filter->element;?></td>
</tr>
<?php } ?>
<?php if($this->filter_action != 'onchange') {?>
<tr>
<td colspan="2" style="text-align:right;">
<input type="button" class="button" value="<?php echo _GO;?>" name="filter" />
</td>
</tr>
<?php }?>
</table>
<?php }?> <br style="clear:both;" />
<br />
<?php if(count($this->rows) == 0){?>
<div class="emptyDataMessage"><?php echo $this->emptyDataMessage;;?></div>
<?php }else{
$firstRecord = $group[0];
$companyName = $firstRecord->jos_annuaire___structure; //name of the table
echo "<p>Company:$companyName</p>";
foreach($this->rows as $group){?>
<table class="fabrikTable">
<tr><th>Structure</th></tr>
<?php
$c = 0;
foreach($group as $row){
?>
<tr class="oddrow<?php echo $c;?>">
<td><?php echo($row->jos_annuaire_noms___Nom);?></td>//name of the joined table
</tr>
<?php $c = 1-$c;
?>
</table>
<?php }
if( $this->canDelete ){?>
<label><input type="checkbox" id="table_<?php echo $this->table->id;?>_checkAll" /><?php echo _CHECK_ALL;?></label>
<?php
}
print_r($this->hiddenFields);?>
<?php echo $this->nav;
echo $this->deleteButton;
?>
</form>

*******

Thanks
PIRINA
 
Code:
<?php /**
 * @package fabrik
 * @version 1.0.4
 * @Copyright (C) Rob Clayburn
 * @license GNU/GPL [url]http://www.gnu.org/copyleft/gpl.html[/url]
 */
/* MOS Intruder Alerts */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
?>

<h1><?php echo $this->table->label;?></h1>
<div><?php echo $this->table->intro;?></div>
<form action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikTable">
<?php if($this->showAdd){?>
  <span class="pagenav">
   <a href="<?php echo $this->addRecordLink;?>"><?php echo _ADD_RECORD;?></a>
  </span>
<?php }?>
<?php if($this->showCSV){?>
  <span class="pagenav">
   <a href="<?php echo $this->csvLink;?>"><?php echo _EXPORT_TO_CSV;?></a>
  </span>
<?php }?>
<?php if($this->showRSS){?>
  <span class="pagenav">
   <a href="<?php echo $this->rsslink;?>"><?php echo _SUBSCRIBE_RSS;?></a>
  </span>
<?php }?>
<?php if($this->showFilters){?>
<table class="filtertable">
  <tr>
   <th colspan="2" style="text-align:left"><?php echo _SEARCH;?>:</th>
  </tr>
  <?php foreach($this->filters as $filter){?>
  <tr>
   <td><?php echo $filter->label;?></td>
   <td style="text-align:right;"><?php echo $filter->element;?></td>
  </tr>
  <?php } ?>
  <?php if($this->filter_action != 'onchange') {?>
  <tr>
   <td colspan="2" style="text-align:right;">
   <input type="button" class="button" value="<?php echo _GO;?>" name="filter" />
   </td>
  </tr>
  <?php }?>
</table>
  <?php }?> <br style="clear:both;" />
<br />
  <?php if(count($this->rows) == 0){?>
   <div class="emptyDataMessage"><?php echo $this->emptyDataMessage;;?></div>
  <?php }else{
   $firstRecord = $group[0];
   $companyName = $firstRecord->jos_annuaire___structure; //name of the table
   echo "<p>Company:$companyName</p>";
   foreach($this->rows as $group){?>
   <table class="fabrikTable">
     <tr><th>Structure</th></tr>
     <?php
     $c = 0;
     foreach($group as $row){
      ?>
     <tr class="oddrow<?php echo $c;?>">
      <td><?php echo($row->jos_annuaire_noms___Nom);?></td>
     </tr>
     <?php $c = 1-$c;
				}
     ?>
   </table>
<?php }
}
if( $this->canDelete ){?>
<label><input type="checkbox" id="table_<?php echo $this->table->id;?>_checkAll" /><?php echo _CHECK_ALL;?></label>
<?php
}
print_r($this->hiddenFields);?>
<?php echo $this->nav;
echo $this->deleteButton;
?>
</form>

you had two "}" missing in various places in the file

Cheers
Rob
 
Hi Rob,

I paste your new instructions.
My table doesn't display the Companies_name, and anything else.

Best regards
PIRINA
 

Attachments

  • Capture1.gif
    Capture1.gif
    1.9 KB · Views: 148
  • Capture1.gif_thumb
    5.2 KB · Views: 145
doesnt look like you hav published "jos_annuaire_noms___Nom" to the table - you need to do that to be able to access it

hth
Rob
 
Hi Rob,

Yes it was not published. Now it's done and I'm confused about the result. It's sure my basic english in the previous posts.

I try one more time :
I have a master table "jos_annuaire" (a directory of different organisations). Each organisation have one or many contacts persons (with gender, first name, family name...) in a table "jos_annuaire_noms".
The 1st one have a left join to the 2nd one, thanks to the id_annu (pk of the first, and the database join element for the 2nd).

In my TableView I want to see some elements only from the master table "jos_annuaire", not from the joined one. And even if I have more than one contact for one organisation, I would like to see the organisation only one time in the TableView.

All the detailed information for one Organisation and all their contacts have to be shown in the view TableRowDetails and modified or add thanks to the view EditForm.

Can you help ?

Thanks
PIRINA
 
why not simply create a new fabrik table to "jos_annuaire" with a link pointing to the current "jos_annuaire" detailed view?
that way you dont need a custom template
 
which bit?
1) Create a new fabik table whose database table is "jos_annuaire"
2) This creates new elements etc that can be show/hidden on the table view
3) Edit the fabrik table's "detailed link" url to point to the orginal fabrik table's detailed view.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top