Hi there,

I needed to have the Matrix Field work with Views Fields. This I found to be difficult due to the way Matrix module stores its data. I've fixed the module, and now it works with CCK which creates the Tables, and allows us to leverage all of the CCK API. At the same time, this then gives us a chance to extract this information, and display it in views through Fields (and not just Full Nodes/Teasers).

I'd like to have this module merged with Matrix module, instead of us creating a new cck_matrix project.
The only thing is that I have not written an upgrade path, and I wouldn't know where to start to get the old matrix modules users, able to run cck_matrix (attached).

If you think its better to start a new project, I'll do so.

Otherwise, please take a look at the fixes. A lot of what has been done has been leveraged off of Matrix module, there are several changes.

I've added the following to the README.txt file if you plan to merge the two.
VERY IMPORTANT NOTES:
---------------------
Since this module now works with Creating Dynamic CCK Tables, you have to setup the Rows and Columns Field Settings
* found at: admin/content/node-type/[content-type]/fields/[matrix-field]
Rows and Columns need to have key|value pairs. Eg:
Rows:
1_day|1 Day, 1 night
2_day|2 Days, 1 night
Columns:
1_person| 1 Person
2_person| 2 People Sharing

This will create columns in the Database under the content_field_[matrix_field] table:
select * from content_field_greg_matrix;

+-------+-------+-------+--------------------------+--------------------------+
| vid   | nid   | delta | field_matrix_1_person    | field_matrix_2_person    |
+-------+-------+-------+--------------------------+--------------------------+

Rows are saved as the Delta, and the amount of Rows (2 in the example above) will equal the amount of rows available on node/add/[content-type]

This allows us to display the Matrix field in Views as Fields.

VIEWS:
------
This module is now views compatible. Atleast for Fields. And possibly filtering on the Delta. Filtering for NOT EQUAL TO works, but not much else at the moment. Patches in this regard are welcome.

============
Thanks,
Greg

CommentFileSizeAuthor
cck_matrix.zip12.85 KBmckeen_greg

Comments

peterlambert’s picture

Hi mckeen_greg,

I do like your module. Is it possible to get only one cell (of the cck matrix field) in the list of Fields in Views? This way, the CCK Matrix Field could be 'unfolded' in a single table which is necessary, as far as I know, to export the View as an XLS file (using a Feed).

Any thoughts on this?

Thanks!
Peter

mckeen_greg’s picture

Some work needs to be done to themeing, and workings of the Views Code. I was pushed to get something working, and I just needed to display the entire table as a whole field, so I made that work. Also, the way in which Im doing it is kind of a hack, and this needs serious work to do it properly.

If you'd like to have that done, and submit a patch, I'd be more than happy to apply it.

murz’s picture

subscribe

brpubs’s picture

subscribe

batandwa.sb’s picture

I tried this module but I get the following error:

user warning: Incorrect column name 'field_test9_sit ' query: update_sql /* superadmin : update_sql */ CREATE TABLE content_field_test9 ( `vid` INT unsigned NOT NULL DEFAULT 0, `nid` INT unsigned NOT NULL DEFAULT 0, `delta` INT unsigned NOT NULL DEFAULT 0, `field_test9_sit ` LONGTEXT DEFAULT NULL, `field_test9_amet` LONGTEXT DEFAULT NULL, PRIMARY KEY (vid, delta), INDEX nid (nid) ) /*!40100 DEFAULT CHARACTER SET utf8 */ in D:\Code\Nurizon\includes\database.inc on line 550.
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') SELECT vid, nid, 0, FROM content_type_person' at line 1 query: content_alter_db /* superadmin : content_alter_db */ INSERT INTO content_field_test9 (vid, nid, delta, ) SELECT vid, nid, 0, FROM content_type_person in D:\Code\Nurizon\sites\all\modules\cck\includes\content.admin.inc on line 1552.

I noticed that `field_test9_sit ` contains a space and I have tested this several times, making sure I trim my text when entering.
I can't seem to be able to debug this can anyone please advise.

intrafusion’s picture

Status: Active » Closed (won't fix)