Forums

linked DBmultirecordLoader-fields list of both joined tables

Benvenuto 21 Jun, 2013
Hy! It's my first post. Thank you all in advance.
I'm using two linked DB multirecord loader, through the definition of associated models in their configuration. The two DB multirecord loader are in the submit event.
By this way, I can display all records (of both joined tables) through Data displayer configuration.
I need one of this field to be a link to another form.
In my example, I joined two tables (i.e. Articles and Authors), and I can display the list of article name and writer names, specifying these fields names in "Display fields" of Data Displayer of Articles DB mutlirecord loader (i.e. article_name:Article,Authors.author_name:Writer where Authors is the name of the joined model).
What I need is that the name of the article become a link to another form (href=\"index.php?option=com_chronoforms&chronoform=article_details).
I've found an example to generate such a link through a Custom Code action in the submit event instead of the Data Displayer configuration. The example works only if I put fields of just one model - one DB multirecord loader in the list (i.e.article_name:Article). I need to have in the same list also joined fields (i.e Authors.author_name:Writer).
Could you help me?
Vince
GreyHead 23 Jun, 2013
Hi Vince,

I'd do this - as you have suggested - using a Custom listing. If you give Model ID's to both DB MultiRecord Loaders then you should be able to access {article.article_name} to include in the URL.

Bob

NB Article names are not necessarily URL safe - you may need to URLencode the value, or better use the article ID or alias to pass to the second form.
neuronageek 29 Jun, 2013
Hi.

I have a similar problem. fields and data under second model id (the internal data who complete the info from the main table) are not accesible (AFAIK). Debugger shows that those records are in model "acc" (articles in your case) and for every record I get a "est" sub array (model) created by the second loader with the data obtained by the join statement (in your case, the data from "Author")

I need export all info using xls-export action, but this only "see" one model data (acc) and ignore the fields on second (est). My only solution will be tweek xls-export code and create a customized export action.

If you find a solution valid for you, please share!

thanks
GreyHead 30 Jun, 2013
Hi neuronageek,

If you want a flat table to export then you almost certainly don't want two different model IDs; they are there to keep the data separate.

What happens if you remove the Model ID from both?

BTW: if you turn the Debugger on then you can see the MySQL query that is being generated, that can be useful to see exactly what is happening.
neuronageek 30 Jun, 2013
Hi, Bob. I need link both tables because one have the id (name) of restaurant and the other have the rest of the info of restaurant (address, contact info, et).
I must join both tables and put some fields of each in the export file.

I have tried not use model id's, but nothig is exported, and DB record loaders needs models to stablish the relation.

On debugger, the sql is perfect, and on phpmyadmin works like a charm.

I think its a bug in the way xls_export treats model names when referencing fields of different models, for that reason i will repare a custom routine.

Thanks for your info
GreyHead 01 Jul, 2013
Hi Neuronageek,

You are right, sorry.

If you add code like this after the DB Multi-Record Loaders it will flatten the data array; this was written for the example in the FAQ so the Model IDs will need to be changed as necessary:
<?php
foreach ( $form->data['Articles'] as $k => $v ) {
  foreach ( $v['User'] as $kk => $vv ) {
    $form->data['Articles'][$k][$kk] = $v['User'][$kk];
  }
  unset($form->data['Articles'][$k]['User']);
}
?>

Note that if you use this AND you want to display the data then you should leave out any Model IDs from the 'Display Fields' box on the Data Displayer tab.
neuronageek 01 Jul, 2013
Thanks, Bob.
At this time, I have finished a preliminary version of a hacked "xls export GH-NG" action based on "CSV export GH" adapting the code to generate an HTML table and implementing a "Join" box to enter the join statement, and removing lot of code to simplify operation.

This is the options panel
[attachment=2]options.jpg[/attachment]
This is the form example:
[attachment=1]4.jpg[/attachment]
and the excel file opened:
[attachment=0]5.jpg[/attachment]

(PD: When I finish all developping of site, i will license it; I'm working inside a IT company, and I star this proyect using Breezingforms licensed, but after several problems with the integration of components, I decide to use Chronoforms. Now, almost all my functions works in this environment :-)

Thanks for your help, and if I will help somebody, feel free to contact me (but I have not expereience with Chronoforms until 2 weeks...)
This topic is locked and no more replies can be posted.