I am using print module. I am also using devel module. In print.tpl.php file, I see a php code that prints the content as print $content.
I don't want to print the entire content. I think content is an array. How can I print manually some fields from the content variable using the devel module or in php?
Thanks. D
-
1.
print render($content['field_machine_name']);
Get this error: Fatal error: Only variables can be passed by reference in /..sites/all/modules/print/print.tpl.php on line 100
php print $content['field_machine_name'];
I get left error only (<)
-
3.
print $fields['field_vehicle_options']->content;
I get completely blank
I am using bartik 7.22.
- themes > bartik > template.php
Added the below function.
function bartik_preprocess_print(&$vars, $hook) {
// Global node.
$node = $vars['node'];
// Create a var and render using field_view_value
$vars['test'] = field_view_value('node', $node, 'field_price', $node->field_price[$node->language][0]);
}
- themes > bartik > template > print.tpl.php
I added: print render($test);
- I went to my page http://bettylist.com/ac/node/12 > clicked printer friendly link > I did not see the value of variable.
In print.tpl.php, what works:
print $content; //I GET CONTENT IN PRINT PAGE
print dsm($title); // I GET VALUE OF TITLE IN PRINT PAGE
Please advise. Thanks, D
It worked. I have added one more variable as below:
function bartik_preprocess_print(&$vars, $hook) {
// Global node.
$node = $vars['node'];
// Create a var and render using field_view_value
$vars['price'] = field_view_value('node', $node, 'field_price', $node->field_price[$node->language][0]);
// Create a var and render using field_view_value
$vars['vehicleOption1'] = field_view_value('node', $node, 'field_vehicle_option_1', $node->field_vehicle_option_1[$node->language][0]);
}
In print.tpl.php, I added
print render($test);
print render($vehicleOption1);
But I am only getting the value of the last variable $vars'vehicleOption1'.
Please advise.
price
andvehicleOption1
, but you didn't declare variabletest
so you couldn't use it (as you did in your print.tpl.php file).