[closed] loop / for or foreach / print matrix

Author Message

scrieler _

Monday 06 July 2009 6:26:42 am

heya,

I got the problem to print a matrix and compare the cells.
I want to print a matrix with 3 cols and X rows.
I have to compare cell 1 and cell 2 of every row.

how to start? tried some loops but don't get cell 1 and 2 of row in one step to compare..

Christian Rößler

Monday 06 July 2009 8:57:20 am

heyho,

try this:

{* fetch node object by node-id *}
{def $mynode=fetch('content','node', hash('node_id',283))}

{def $mymatrix=$mynode.data_map.MATRIX_ATTRIBUTE_NAME_HERE.content.matrix}

{* loop every row in the nodes matrix *}
{foreach $mymatrix.rows.sequential as $matrixrow}

    {*debugging*}
    {*$matrixrow|attribute('show')*}

    {* check if col1 and col2 are even *}
    {if eq($matrixrow.columns.1, $matrixrow.columns.2)}
        column 1+2 in row {$matrixrow.identifier} are equal!<br/>
    {else}
        column 1+2 in row {$matrixrow.identifier} are NOT equal!<br/>
    {/if}
    
{/foreach}

cheers, chris

Hannover, Germany
eZ-Certified http://auth.ez.no/certification/verify/395613

scrieler _

Tuesday 07 July 2009 2:28:28 am

aloah, vielen dank, leider zu spät gesehen :]

my dirty solution is like this:

{foreach $Rows as $index => $Columns sequence array( 'bglight', 'bgdark') as $style}

   {for 0 to $colcounter as $counter}
      {$Columns.columns.$counter}
   {/for}

{/foreach}
 

best regards

---------------------------------------------------------------
irc://irc.freenode.net#ezpublish
irc://irc.freenode.net#ezpublish.de

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 21:09:39
Script start
Timing: Jan 18 2025 21:09:39
Module start 'layout'
Timing: Jan 18 2025 21:09:39
Module start 'content'
Timing: Jan 18 2025 21:09:41
Module end 'content'
Timing: Jan 18 2025 21:09:41
Script end

Main resources:

Total runtime1.5780 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.0313152.6406
Module start 'layout' 0.00570.0030 740.671939.4766
Module start 'content' 0.00871.5680 780.1484499.7266
Module end 'content' 1.57670.0013 1,279.87508.1250
Script end 1.5779  1,288.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.1968160.0002
Check MTime0.00130.0794160.0001
Mysql Total
Database connection0.00070.046710.0007
Mysqli_queries1.533097.1476570.0269
Looping result0.00050.0337550.0000
Template Total1.538597.520.7692
Template load0.00210.135720.0011
Template processing1.536397.359920.7682
Template load and register function0.00020.011810.0002
states
state_id_array0.00190.119110.0019
state_identifier_array0.00270.168620.0013
Override
Cache load0.00170.1070210.0001
Sytem overhead
Fetch class attribute can translate value0.00070.043020.0003
Fetch class attribute name0.00110.068430.0004
XML
Image XML parsing0.00020.013620.0001
class_abstraction
Instantiating content class attribute0.00000.000430.0000
General
dbfile0.00080.0521100.0001
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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs