I am working on Catalyst MVC framework to create a web page for a database. I am not a full time programmer as such. But I know basics of perl and java. I am a biologist. I have written a template file(view.tt) which is having a table. I need to link the contents of this table to another table which is written in one more template file. I am not able to link these two templates(as I am not able to generate the url properly). Can any one help or guide me to resolve this issue.
The following code is for the second template file:
<h4>Analyses Table</h4>
<table id="analysis_table" width="90%">
<thead>
<tr>
<th align="center" valign="center">Dataset</th>
<th align="center" valign="center">Tissue</th>
<th align="center" valign="center">Expression</th>
<th align="center" valign="center">Analysis</th>
</tr>
</thead>
<tbody>
[% FOREACH result IN plets -%]
[% IF result.analysistypename == 'Cancer' -%]
[% matches = result.datasetname.match('(\w+) (\w+)') %]
<tr>
<td align="left" valign="top">[% result.datasetname %]</td>
<td align="left" valign="top">[% result.expression %]</td>
<td align="left" valign="top">[% result.datatype %]</td>
<td align="left" valign="top">[% result.generankpercentile %]</td>
</tr>
[% END -%]
[% END -%]
</tbody>
<tfoot>
<tr>
<th align="center" valign="center">Dataset</th>
<th align="center" valign="center">Tissue</th>
<th align="center" valign="center">Expression</th>
<th align="center" valign="center">Analysis</th>
</tr>
</tfoot>
</table>
The following piece of code is in my first template which has the table to be hyperlinked(view.tt)
<h4>Analyses Summary table</h4>
<table id="score_table" width="50%">
<thead>
<tr>
<th align="centre" valign="centre"> Analysis Type</th>
<th align="centre" valign="centre">Score</th>
</tr>
</thead>
<tbody>
[% FOREACH score IN gene.whs -%]
[% plots = [ ['Cancer', score.cancer_vs_normal_over, score.cancer_vs_normal_under],
['Bladder cancer', score.bladder_cancer_over, score.bladder_cancer_under],
['Brain and CNS cancer', score.brain_and_cns_cancer_over, score.brain_and_cns_cancer_under],
['Breast Cancer', score.breast_cancer_over, score.breast_cancer_under],
['Cervical Cancer', score.cervical_cancer_over, score.cervical_cancer_under],
['Colorectal cancer', score.colorectal_cancer_over, score.colorectal_cancer_under],
]
%]
[% FOREACH plot IN plots %]
<tr>
<td> [% pl0t.0 %]</td>
<td> [% pl0t.1 %] </td>
<td> [% pl0t.2 %] </td>
<td> [% (pl0t.1 + 5 ) / (plot.2 + 5) | format('%5.2f') %] </td>
</tr>
[% END %]
[% END %]
</tbody>
<tfoot>
<tr>
<th align="centre" valign="centre"> Analysis Type</th>
<th align="centre" valign="centre">Score</th>
</tr>
</tfoot>
</table>
Hi Ret, Thanks a lot and sorry for late reply. As you have understood my aim is to have a 'live' link between the summary table and a second table loaded with results. I have somehow linked the templates by another way.I had to hyperlink in first template to second template. My hyperlinking is in the foreach loop which looks something like this.
[% FOREACH plot IN plots %]
<tr>
<td><a href="[% c.uri_for(c.controller('gene').action_for('sample'))%]/[% plot.0 %]>[% plot.0 %]</a></td>
<td> [% pl0t.1 %] </td>
<td> [% pl0t.2 %] </td>
<td> [% (pl0t.1 + 5 ) / (plot.2 + 5) | format('%5.2f') %] </td>
</tr>
[% END %]
This line is linking correctly to the second template(sample.tt). The second template contains a series of tables. when the hyperlink is clicked on the first table, the table corresponding to that link should be displayed. I have successfully linked the templates. I have created a sub routine in my controller(gene.pm) also for the purpose of linking the templates. I am facing a problem in achieving my goal. The html part inthe second template(sample.tt) is functioning properly,but the template toolkit is not functioning. I am able to see the change in the url but in the page it is not reflected.
Below is the subroutine for the second template:
sub sample :Path('sample'):Args(1) {
my($self,$c,$plot)=@_;
my @plets = $c->model('GeneDB::genewhs')->search({
Analysistypename => @plet,
});
$c->stash->{plets}=\@plets;
$c->stash->{template}='gene/sample.tt';
}
If in case the question is not clear, please let me know...i would be obliged to clear it..
Thanks in advance..