user3767262
user3767262

Reputation: 43

Drupal 7 php loops and rendering images dynamically

I currently have a custom content type of type my article in which i have a slider attached using node-tpl.php the slider is working fine my problem is that i have image fields in this content type and i want them to be rendered in the

  • so that they are displayed inside the slider i cant seem to add the php snippet to the
  • elements am currently using this code print render($content['field_images'][i]); where i is the index in the field images array to be rendered

    Full php snippet`

    <?php
    $i=0;
     $array=$html->find('li');
    ?>
     <?php
     foreach ($array as $value){
     print render($content['field_images'][i]);
     $i=i+1;}
     ?>
    

    Upvotes: 1

    Views: 531

  • Answers (1)

    Muhammad Reda
    Muhammad Reda

    Reputation: 27033

    The following can get you started.

    foreach($content['field_images']['#items'] as $key => $value) {
        print render($content['field_images'][$key]);
    }
    

    Upvotes: 1

    Related Questions