jquery - Trying to write a foreach argument for a drupal7 cck field -
i using drupal 7 , jquery , cycle2 feature. followed example code on page. http://jquery.malsup.com/cycle2/demo/basic.php code looks this:
<div class="cycle-slideshow"> <img src="http://malsup.github.io/images/p1.jpg"> <img src="http://malsup.github.io/images/p2.jpg"> <img src="http://malsup.github.io/images/p3.jpg"> <img src="http://malsup.github.io/images/p4.jpg"> i created drupal cck multiple photo upload field called 'field_slider_photo'. , in node template wrote this.
<div class="cycle-slideshow"> <?php print render($content['field_slider_photo']); ?> </div> but display photos @ once. want them play in slideshow 1 @ time. need use array or foreach argument ? want end example:
<div class="cycle-slideshow"> <?php print render($content['field_slider_photo']); ?>array1 <?php print render($content['field_slider_photo']); ?>array2 <?php print render($content['field_slider_photo']); ?>array3 </div> i got working there better way write this?
<div class="cycle-slideshow"> <?php print render($content['field_slider_photo'][0]); ?> <?php print render($content['field_slider_photo'][1]); ?> <?php print render($content['field_slider_photo'][2]); ?> <?php print render($content['field_slider_photo'][3]); ?> </div>
you're close, give whirl.
<div class="cycle-slideshow"> <?php foreach($content['field_slider_photo']['#items'] $img): ?> <img src="<?php print file_create_url($img['uri']);?>"> <?php endforeach; ?> </div>
Comments
Post a Comment