[themes] tpl.php file question - solved!!!

barb barb at karasssuite.net
Thu Apr 23 17:30:41 UTC 2009


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

?>


More information about the themes mailing list