Print a table

Author Message

Monday 11 August 2003 8:07:01 am

Hi,

I'm trying to print a nicely formatted table. I've made a Content class named Match and it contains the attributes date, team1 and team2.

My templatecode looks as follows :

{let children=fetch('content',list,hash(parent_node_id,$node.node_id))}
<table border='1'>
<tr>
<td>{attribute_view_gui attribute=$node.object.data_map.date}</td>
<td>{attribute_view_gui attribute=$node.object.data_map.team1}</td>
<td>{attribute_view_gui attribute=$node.object.data_map.team2}</td>
</tr>
</table>
{/let}

My solution prints out several tables for every one instance of the class instead of having one table carrying all instances.

This might be a simple matter but I can't get this right.

Sample code would be very appreciated :)

Regards Hans-Henry

Alex Jones

Monday 11 August 2003 8:35:55 am

Hans-Henry, I believe all you need to do is place the table tags outside of your let. Something along the lines of:

<table border='1'>
{let children=fetch('content',list,hash(parent_node_id,$node.node_id))}
<tr>
<td>{attribute_view_gui attribute=$node.object.data_map.date}</td>
<td>{attribute_view_gui attribute=$node.object.data_map.team1}</td>
<td>{attribute_view_gui attribute=$node.object.data_map.team2}</td>
</tr>
{/let}
</table>

This will ensure that the rows, and the data cells within them are repeated, but the table tags are only pritned once.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

John van der Boom

Monday 11 August 2003 8:48:45 am

You want to print a different table for every Match-object I guess.

I think this code might work:

{let match_list=fetch(content,list,hash(parent_node_id,$node.node_id,class_filter_type,include,class_filter_array,array(-->match_class_id<--)))}
{section name=match loop=$match_list}
{node_view_gui view=tableview content_node=$match:item}
{/section}
{/let}

Create a tableview_match.tpl:

{default content_version=$node.contentobject_version_object}

<table border='1'>
<tr>
<td>{attribute_view_gui attribute=$content_version.data_map.date}</td>
<td>{attribute_view_gui attribute=$content_version.data_map.team1}</td>
<td>{attribute_view_gui attribute=$content_version.data_map.team2}</td>
</tr>
</table>

{/default}

Do not forget to edit your override.ini(.append) file by entering something like this:

[tableview_match]
Source=node/view/full.tpl
MatchFile=node/view/tableview_match.tpl
Subdir=templates
Match[class]=-->match_class_id<--

edit the -->match_class_id<-- with the id number of the match class.

Monday 11 August 2003 8:53:02 am

Thanks for your reply, but does not print it in one table.
Every instance still gets printed as one table :(

And yes, I've cleared the cache...

John van der Boom

Monday 11 August 2003 8:55:45 am

Are you replying to my code or Alex's one?

Monday 11 August 2003 11:13:10 pm

Thanks for your suggestions but both solutions print a new table for every new instance of the class instead of printing it all in one big table.

Alex Jones

Tuesday 12 August 2003 6:51:55 am

Hrrrrm, did you make sure to clear the cache after testing both methods? Also, are there any other loops or fetch around the code you posted that we don't know about?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Tuesday 12 August 2003 11:10:11 am

Yes, I'm positive. I deleted the cache directory between tests because the cache usually cause problems even though I have disabled cache.
No, there's no loops or fetch that I know about.
This puzzles me...

I'm running eZ 3.1-1 build 2703 with the demo data installed.

It shouldn't be that hard doing such an easy thing, I hope ;)

John van der Boom

Tuesday 12 August 2003 3:01:04 pm

<quote>
You want to print a different table for every match-object I guess.
</quote>

Oops, I thought you wanted to print every instance in a different table.
To accomplish ONE big table with all the instances in it, you should loop only the <tr> ... </tr> part. I put some remarks {* .. *} what every part is doing.

{* Start Code *}

{* start 1 table :) *}
<table border='1'>
{* put all match instance in array match_list *}
{let match_list=fetch(content,list,hash(parent_node_id,$node.node_id,class_filter_type,include,class_filter_array,array(-->match_class_id<--)))}
{* loop over every element in the list *}
{section name=match loop=$match_list}
{* code that should be looped*}
<tr>
<td>{attribute_view_gui attribute=$match:item.contentobject_version_object.data_map.date}</td>
<td>{attribute_view_gui attribute=$match:item.contentobject_version_object.data_map.team1}</td>
<td>{attribute_view_gui attribute=$match:item.contentobject_version_object.data_map.team2}</td>
</tr>
{* end code that should be looped*}
{/section}
{* close let *}
{/let}
{* close table *}
</table>

{* End Code *}

Good luck

Wednesday 13 August 2003 2:09:03 am

Thanks for all your code suggestions, but it still won't work :(
I'll download and do a fresh install from the latest svn and test the code there.

I won't give up that soon because I really like the eZ Publish way of doing things. Looking forward to try the 3.2 release :)

Maybe this table code should have been written in the documentation...

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:11:04
Script start
Timing: Jan 18 2025 16:11:04
Module start 'layout'
Timing: Jan 18 2025 16:11:04
Module start 'content'
Timing: Jan 18 2025 16:11:06
Module end 'content'
Timing: Jan 18 2025 16:11:06
Script end

Main resources:

Total runtime1.4235 sec
Peak memory usage4,096.0000 KB
Database Queries80

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.9063152.6094
Module start 'layout' 0.00490.0022 741.515639.4297
Module start 'content' 0.00711.4147 780.9453669.0156
Module end 'content' 1.42190.0016 1,449.960924.1953
Script end 1.4235  1,474.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2317160.0002
Check MTime0.00140.0978160.0001
Mysql Total
Database connection0.00050.034210.0005
Mysqli_queries1.315192.3841800.0164
Looping result0.00100.0670780.0000
Template Total1.397098.120.6985
Template load0.00220.157220.0011
Template processing1.394897.980320.6974
Template load and register function0.00010.007210.0001
states
state_id_array0.00070.048810.0007
state_identifier_array0.00190.131720.0009
Override
Cache load0.00220.15471130.0000
Sytem overhead
Fetch class attribute can translate value0.00570.401130.0019
Fetch class attribute name0.00330.2286120.0003
XML
Image XML parsing0.00130.091530.0004
class_abstraction
Instantiating content class attribute0.00000.0027170.0000
General
dbfile0.00100.0724220.0000
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
11content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 47
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs