Trouble looping bi-directional images data in Pods CMS
-
Hi there!
I’m building a record label website and I’m stuck in a loop error. Hopefully someone can help me out with this. I am losing my mind.
In a pod (“artists”) I want to pull all one artist’s albums from another pod (“releases”) through the bi-directional field (“releases_conn”).
Everything works out fine except the images (“releases_img”) shows up in the wrong order in the for loop.Code:
if (is_array($release_conn)) { echo '<h3>Releases</h3>'; echo '<ul>'; for ($i=0; $i<count($release_conn); $i++) { $rl = $release_conn[$i]; // Check if compilation (various artists) if ($rl['compilation'] == 1) { $release_title = $rl['name']." (Various Artists)"; } else { $release_title = $rl['name']; } $thumb = $artists->get_field('release_conn.releases_img'); $thumb = $thumb[$i]; // Get thumbnail image size $size = 'thumbnail'; if(!empty($thumb)) { $attachment_id = $thumb['ID']; $sized = image_downsize($attachment_id,$size); echo '<li>'; if(is_array($sized)) { echo '<a href="releases/'.$rl[slug].'/"><img src="'.$sized[0].'" alt="'.$release_title.'"></a><br />'; } } echo '<p><a title="'.$release_title.'" href="releases/'.$rl[slug].'/">'.$release_title.'</a><br />'.$rl['releases_format'].' ('.date("Y", strtotime($rl['releases_releasedate'])).')</p></li>'; } echo '</ul>'; }
The images shows up in a different order than the other info. I guess it’s not correct to pull this inside the for loop as :
$thumb = $artists->get_field('release_conn.releases_img'); $thumb = $thumb[$i];
But I don’t know what else to do.
I need to connect the image files [guid] to the correct pod item (ID).
Please help!Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Trouble looping bi-directional images data in Pods CMS’ is closed to new replies.