Been trying for hours now to figure out why the custom variable I create for the node I have the matrix field in is not accessible in content-field-field_fieldname.tpl.php.
I have a CCK field that sets a currency symbol. I have excluded that in the content type as it shall not be viewed on its own.
To make things nice and clean I created:
<?php
function phptemplate_preprocess_node(&$variables) {
$variables['cur_symbol'] = $variables['field_currency'][0]['view'];
}
?>
When I use the variable on the node page it prints just fine, but trying to use it in the matrix field tpl.php nothing happens.
I know $node is available in the template and I have done a print_r on it and seen that the original CCK field is in there. Problem though is that where it is available for the node it now misses the 'view' part.
It is available in the content part, but I simply can't figure out how to be able to use it.
If I do a print_r($node->content) I get a complete blank page...
When doing just print_r($node) I get the result below (I have stripped out everything else).
There are several #children in there containing the currency symbol...
[content] => Array
(
[group_rates] => Array
(
[#type_name] => car_types
[#context] => full
[#group_name] => group_rates
[#post_render] => Array
(
[0] => fieldgroup_wrapper_post_render
)
[#weight] => 6
[group] => Array
(
[#parents] => Array
(
)
[#title] => Rates & Availability
[#value] =>
[#collapsed] =>
[#collapsible] =>
[#tree] =>
[#description] =>
[#type] => fieldgroup_fieldset
[#attributes] => Array
(
[class] => fieldgroup group-rates
)
[#required] =>
[field_currency] => Array
(
[#type_name] => car_types
[#context] => full
[#field_name] => field_currency
[#post_render] => Array
(
[0] => content_field_wrapper_post_render
)
[#weight] => 29
[field] => Array
(
[#description] =>
[items] => Array
(
[0] => Array
(
[#formatter] => plain
[#node] => stdClass Object
*RECURSION*
[#type_name] => car_types
[#field_name] => field_currency
[#weight] => 0
[#theme] => text_formatter_plain
[#item] => Array
(
[value] => 1
[safe] => 1
[#delta] => 0
)
[#title] =>
[#description] =>
[#theme_used] => 1
[#printed] => 1
[#type] =>
[#value] =>
[#prefix] =>
[#suffix] =>
[#children] => £
)
[#title] =>
[#description] =>
[#children] => £
[#printed] => 1
)
[#single] => 1
[#attributes] => Array
(
)
[#required] =>
[#parents] => Array
(
)
[#tree] =>
[#context] => full
[#page] => 1
[#field_name] => field_currency
[#title] => Currency
[#access] => 1
[#label_display] => hidden
[#teaser] =>
[#node] => stdClass Object
*RECURSION*
[#type] => content_field
[#children] => £
[#printed] => 1
)
[#title] =>
[#description] =>
[#children] => <div class="field field-type-text field-field-currency">
<div class="field-items">
<div class="field-item odd">
£ </div>
</div>
</div>
[#printed] => 1
)
Comments
Comment #1
tsvenson commentedOki, finally sorted it out. The lovely variable I had to print is:
Isn't Drupal fun lol!
Comment #2
tsvenson commented