As far as I know drupal only passes the node object to node-tpl. You will have to process other non-related variables before trying to use them in your tpl file.
mhm - i thought so already, but wasnt't sure. so if i see this right, i have to preprocess the variables in the template.php in order to make new variables available for the node script?
i am doing this for the first time and have hardly any experience in php - so i am really puzzled about making new variables available thru template.php. any help would be appreciated or a link to a good manual? (or do i have to learn php from scratch ;) i've checked out quite some manuals but i don't really understand the processing.... thx b#
In Pro Drupal Development this process is explained in detail. Maybe it is hard to grasp because you have to understand the Theme Registry.
A sidestep: Assuming node-audio is a CCk-node, did you consider using CCk-computed field.?
-----Oorspronkelijk bericht----- Van: themes-bounces@drupal.org [mailto:themes-bounces@drupal.org] Namens barb Verzonden: donderdag 9 april 2009 17:31 Aan: A list for theme developers Onderwerp: Re: [themes] tpl.php file question
As far as I know drupal only passes the node object to node-tpl. You will have to process other non-related variables before trying to use them in your tpl file.
mhm - i thought so already, but wasnt't sure. so if i see this right, i have to preprocess the variables in the template.php in order to make new variables available for the node script?
i am doing this for the first time and have hardly any experience in php - so i am really puzzled about making new variables available thru template.php. any help would be appreciated or a link to a good manual? (or do i have to learn php from scratch ;) i've checked out quite some manuals but i don't really understand the processing.... thx b#
_______________________________________________ themes mailing list themes@drupal.org http://lists.drupal.org/mailman/listinfo/themes
ahojte!
In Pro Drupal Development this process is explained in detail. Maybe it is hard to grasp because you have to understand the Theme Registry.
A sidestep: Assuming node-audio is a CCk-node, did you consider using CCk-computed field.?
sintjago! thx so much for your help! i looked at cck-computed field but was rather hesitant to use it. so in the end after asking around and trying to define the variables in template.php (and starting finally to learn php basics myself) i got the solution. it was really simple actually. to find out, how the node.tpl.php is actually build up, this was included in the code of node-audio.tpl.php:
global $user; if ($user->uid == '1') { print "<pre>"; print_r($node); print "</pre>"; }
so - there the nice code lay, and then it got clear, that the solution was, to include into the $file - this here: $file = $node->audio['file'];
so template.php was left out. maybe not an 'aesthetic' solution but rather dirty, but it's doing the job for me. so this is the whole code, and this the output: http://okno.be/vodnik-vitaminC2
<?php
//added by bundes - show the converted audio downloads $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio['file']; $filepath = $file->filepath; $type = explode(".", basename($filepath));
// print_r($filepath);
if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output;
//end added by bundes
?>