Array de Imagens no .tpl

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
pirex360's picture

Boa Tarde,

Estou a criar um .tpl para um tipo de conteudo...onde quero criar uma Div lateral com um um campo de imagens que pode ter número ilimitado de imagens.

já tentei este código e não consegui...alguém já tentou fazer isto ?

<?php
foreach ($node->field_fotopagina as $image) {
                  if(
$image['filepath']){
                     
$img_thumbnail = theme('image_style', 'recorte', $image['filepath'], '',$image['data']['title']);
?>

<?php
echo $base_path.'sites/default/files/pagina/'.$image['filename'];
?>
" title="
<?php
echo $image['data']['title'];
?>
">
<?php
print $img_thumbnail;
?>

<?php
}}
?>

Comments

Debugg

utneon's picture

Sim, tens aí alguns erros de PHP. Usa o devel com dsm($node) para fazeres debug e corrigir isso. Vou-te deixar aqui um exemplo de código que fiz algo semelhante.

  <?php
      
//dsm($node);
     
$mediaType = $node->field_media_type['und'][0]['value'];
        if (isset(
$node->field_bestseller_image['und'])) {
         
$images_array = $node->field_bestseller_image['und'];
       }
     
?>

<?php if (isset($images_array) && ($mediaType == "gallery" || !isset($node->field_video_vimeo['und'][0]['value']))) :?>
       <script type="text/javascript" src="/sites/all/themes/nome-do-theme/nivo-slider/js/jquery.nivo.slider.pack.js"></script>
       <script type="text/javascript" src="/sites/all/themes/nome-do-theme/nivo-slider/js/custom.js"></script>
       
       <div id="slider-bestseller">
           <div class="slider_wrapper">
             <div class="slider_home nivoSlider">
           <?php foreach($images_array as $image) : ?>
              <img src="<?php print base_path()."sites/default/files/imagens/bestsellers/".$image['filename']; ?>" rel="<?php print base_path()."sites/default/files/imagens/bestsellers/".$image['filename']; ?>" width="640" height="360" />
             <?php endforeach; ?>
             </div>
         </div>
       </div>
       <script type="text/javascript">
          jQuery(document).ready(function() {
         hp_slider();
          });
      </script>
        <?php elseif ($mediaType == "video") : ?>
      <?php
      
       $video
= $node->field_video_vimeo['und'][0]['value'];
      
preg_match("/(\d{1,})$/", $video, $videoId);
    
      
?>

Funcionou, obrigado !

"If you go to hate something...hate your own destiny..."