Forums / Developer / [closed] loop / for or foreach / print matrix

[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