Relevant modules:
- CCK 5.x-1.6-1
- Matrix Field 5.x-1.2
I'm trying to write my first node-mycontenttype.tpl.php for theming the output of a custom content type.
I read the Handbook about CCK Field Formatters and managed to find the field-variable-names with the output of print_r($node).
But I could not find the variable names of the headers and first columns of that matrix field. They showed up only in an already themed table view (which strangely appeared three times in the output of that print_r) .
I read How to Theme CCK Input forms and with print "<code>"; print_r(array_values($form)); in a custom mycontenttype.edit.tpl.php I found for the header:
[header] => Array
(
[#value] => Array
(
[0] =>
[1] => Basis
[2] => Variante 1
[3] => Variante 2
)
[#post] => Array
(
)
[#programmed] =>
[#tree] => 1
[#parents] => Array
(
[0] => field_notenmatrix
[1] => header
)
[#weight] => 0.001
[#processed] =>
[#sorted] => 1
)
and for the first column:
[first_col] => Array
(
[#value] => Array
(
[1] => Primeira
[2] => Segunda
[3] => Terceira
[4] => Agogô
[5] => Caixa
[6] => Repinique
[7] => Tamborim
)
[#post] => Array
(
)
[#programmed] =>
[#tree] => 1
[#parents] => Array
(
[0] => field_notenmatrix
[1] => first_col
)
[#weight] => 0.002
[#processed] =>
[#sorted] => 1
)
The values I'd like display are
[1] => Basis
[2] => Variante 1
[3] => Variante 2
and
[1] => Primeira
[2] => Segunda
[3] => Terceira
[4] => Agogô
[5] => Caixa
[6] => Repinique
[7] => Tamborim
I discovered them in the node_field table. I then tried to find out how the matrix module accesses them: I started reading the sources in matrix.module and but got lost trying to understand which hooks what.
Maybe this is so basic that my forum-searches revealed nothing that helped me.
Thanks for any advice.
Comments
Use contemplate
Hello absurdo, tudo bem?
I don't know exactly what 'print_r($node)' shows, and what it doesn't. But if you temporarily enable the Content Templates module (http://drupal.org/project/contemplate), it will give you a comprehensive list of variables available at the node level, which you can copy-paste to your node-mycontenttype.tpl.php.
Or you may even prefer keep using the contemplate module, and forget about node-x.tpl.php files.
There seems to be at least one advantage of Contemplate over tpl files (not thoroughly tested yet): if you intend to send your nodes by email using the Send or SimpleNews modules, they will not honor the custom theming in the tpl files, while changes made by Contemplate are reflected in the email.
Durval Tabach
PS - você é percussionista brasileiro?
Durval Tabach
Contemplate doesn't help :(
Hello Durval, tudo bem, e você?
thanks for the suggestion. I tried to let contemplate help me, but unfortunately it only offers stuff like
which all displays the complete matrix. No access to only the [header] or [first_col] variables.
PS: Incrível! Algumas palavras só, já encontrei um brasileiro aqui no d.o! Sou percussionista brasileiro, mas num corpo de um alemão.