Forums / Setup & design / Displaying the contents of a matrix

Displaying the contents of a matrix

Author Message

J Williams

Friday 20 August 2004 11:10:42 am

I have looked throughout these forums but can find little information regarding the use of a matrix datatype. I have created a matrix in one of my classes but cannot work out how to display the contents in table. I have managed to display each row of the matrix using {attribute_view_gui attribute=$node.data_map.matrix_name} but this lacks formatting and the column headers. Can anyone please point me in the right direction.

Many thanks in advance

J Williams

Monday 23 August 2004 7:37:14 am

Maybe no one uses the matrix datatype in a class.

Paul Forsyth

Monday 23 August 2004 7:40:14 am

Have you looked at the ez template file:

design/standard/templates/content/datatype/view/ezmatrix.tpl

paul

J Williams

Monday 23 August 2004 10:06:20 am

thanks for your reply. Maybe some more information might help. I am using EZ Publish 3.41 (svn 7051). However I try and display the contents of the matrix other than attribute_view as above nothing happens. Using the code from the ezmatrix.tpl file still produces a blank, not even the headers.

Alex Jones

Monday 23 August 2004 10:30:31 am

I'm not sure if this will work or not, as the Matrix datatype I am using is a bit old, and modified, but you never know... I have an override template for a Matrix that display product specs. While I don't use a table, it should provide you an idea of hot to accomplish your goals.

{let matrix=$attribute.content}
  {section loop=$matrix.rows.sequential}
    {section show=$:item.columns.1} {* Show the field's value *}
    <div class="Specification">
      <div class="SpecName">
        {$:item.columns.0}
      </div>
      <div class="SpecResult">
        {$:item.columns.1}
      </div>
    </div>
    {/section}
  {/section}
{/let}

I call it from my class override template with:

{attribute_view_gui attribute=$content_version.data_map.item_1_specifications_construction}

Hope this helps,

Alex

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

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

J Williams

Monday 23 August 2004 3:21:18 pm

Hi Alex,

I think my problem is a little bit more fundamental than this. If I don't use any overrides at all and view my matrix in the default template what I see is:-
==================================================================================
Default object view. Click to create a custom template, Node ID: 67, Object ID: 65
Test Matrix

<b>title</b>
Test Matrix

<b>reference</b>
abc

<b>field2</b>
data 1
data 2
data 3
==================================================================================

The first column of data is missing completely. If I create an override using anything other than {attribute_view_gui attribute=$node.data_map.<i>matrix_name</i>} no data is displayed at all. I have tried this on two different installations and the results are the same. My conclusions are that I am probably creating the override incorrectly or overriding the wrong template. I have tried overriding node/view/full with a template matching the class but this gives me a blank. I have tried overriding ezmatrix.tpl but this also gives me a blank although I suspect this only determines the display format of the matrix. I am at a complete loss on this one and any guidance would be greatly appreciated.

steve walker

Tuesday 24 August 2004 12:07:29 am

Have you enabled template debug so you can seed exactly which templates are being used where?

Steve.

http://www.oneworldmarket.co.uk

J Williams

Tuesday 24 August 2004 2:58:56 am

Hi Pete, Alex, Paul,

I hold my hands up, I let frustration get the better of me and let common sense fly out the window. It helps if I override the correct template (/content/datatype/view/ezmatrix.tpl) and then reference the matrix in the full view override. Many thanks for your help guys the matrix is now working correctly and displaying the output in a table formatted exactly as I wanted it.

Paul Forsyth

Tuesday 24 August 2004 5:32:58 am

Thats good news :)

paul

Alex Jones

Tuesday 24 August 2004 7:02:37 am

Great to hear!

Alex

<b>Drop by the eZ Pub: http://ezpub.co.uk/ </b>
[ bald_technologist on the IRC channel: #eZpublish ]

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

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