Forums / Setup & design / Print a table

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...

eZ debug

Timing: Jan 18 2025 11:18:59
Script start
Timing: Jan 18 2025 11:18:59
Module start 'content'
Timing: Jan 18 2025 11:19:00
Module end 'content'
Timing: Jan 18 2025 11:19:00
Script end

Main resources:

Total runtime1.0804 sec
Peak memory usage4,096.0000 KB
Database Queries217

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0077 587.6016180.8516
Module start 'content' 0.00770.9308 768.4531674.0781
Module end 'content' 0.93850.1417 1,442.5313344.4688
Script end 1.0803  1,787.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00570.5293210.0003
Check MTime0.00150.1350210.0001
Mysql Total
Database connection0.00080.074110.0008
Mysqli_queries0.959088.76872170.0044
Looping result0.00360.33052150.0000
Template Total1.041896.420.5209
Template load0.00370.345120.0019
Template processing1.038196.082120.5190
Template load and register function0.00010.010310.0001
states
state_id_array0.00100.092610.0010
state_identifier_array0.00130.123220.0007
Override
Cache load0.00360.33711130.0000
Sytem overhead
Fetch class attribute can translate value0.00380.351240.0009
Fetch class attribute name0.00170.1607120.0001
XML
Image XML parsing0.00150.135140.0004
class_abstraction
Instantiating content class attribute0.00000.0037170.0000
General
dbfile0.00480.4446330.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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