I can't seem to fetch the $node object in my templates - how is this done?

Problem is, that I have some custom CCK fields that I would like to tamper with...

I tried doing so in preprocess_node and preprocess_block, doesnt work.

Thanks

Comments

Ralla’s picture

Ok I solved this myself.

Created block-nodeblock.tpl.php:
print $block->content;

And created node-[content-type-used-as-block].tpl.php:

<?php dpm($node); ?>
<div class="mdColumn6">
  <div class="mdInternalAd">
    <div class="mdInternalAdSub">
    
      <?php if (!empty($node->field_teaser_image_ref[0]['nid'])) : ?>
        <div class="mdImg">
          <?php
          $image = node_load($node->field_teaser_image_ref[0]['nid']);
          print l(theme('imagecache', '300w', $image->field_picture[0]['filepath'],
                                              $image->field_picture[0]['alt'],
                                              $image->field_picture[0]['title']),
                        $node->field_teaser_image_link[0]['value'], array('html' => TRUE)); ?>
        </div>
      <?php endif; ?>
      
      <div class="mdTxt">
        <?php if (!empty($node->title)): ?>
          <h3><?php print $node->title; ?></h3>
        <?php endif;?>
        
        <?php if (!empty($node->body)): ?>
          <?php print $node->body; ?>
        <?php endif;?>
        
        <?php if (!empty($node->field_link)) {
          // Run through the links, and generate a list
          $links = '<ul class="mdLinkList">';
          foreach ($node->field_link as $link) {
            $links .= '<li>' . $link['view'] . '</li>';
          }
          $links .= '</ul>';
          
          print $links;
        }
        ?>
        
      </div>
      
    </div>
  </div>
</div>
Ralla’s picture

Status: Active » Closed (fixed)