Created
December 3, 2015 01:05
-
-
Save nicdford/01b9427b6e22a934a705 to your computer and use it in GitHub Desktop.
A Pods Example on running a loop inside a loop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Library Resource List | |
* | |
* This is the template that displays all pages by default. | |
* Please note that this is the WordPress construct of pages | |
* and that other 'pages' on your WordPress site will use a | |
* different template. | |
* | |
* @package asotin_county_library | |
*/ | |
get_header(); ?> | |
<div id="primary" class="row content-area library-resource-list"> | |
<main id="main" class="site-main columns small-12 medium-8" role="main"> | |
<?php | |
$params = array( | |
'limit' => -1, | |
'expires' => 0 | |
); | |
$resource_category = pods( 'aclib_resource_category', $params ); | |
if ( 0 < $resource_category->total() ) : | |
while ( $resource_category->fetch() ) : ?> | |
<?php $resource_image = $resource_category->field('image'); ?> | |
<div class="category-heading-contain" id="<?php echo $resource_category->field( 'slug' ); ?>"> | |
<h2> | |
<?php echo $resource_category->field( 'name' ); ?> | |
<span class="top"><a href="#top">Back to Top</a></span> | |
</h2> | |
<img src="<?=$resource_image['guid'];?>" alt="<?=$resource_image['post_title'];?>"> | |
</div> | |
<?php | |
$category_slug = $resource_category->field( 'slug' ); | |
$params = array( | |
'limit' => -1, | |
'where' => 'resource_category_item.slug = "' . $category_slug . '"', | |
'expires' => 0 | |
); | |
$resources = pods( 'library_resources', $params ); | |
if ( 0 < $resources->total() ) : ?> | |
<div class="resource-item-container"> | |
<?php while ( $resources->fetch() ) : | |
$resources_url = $resources->field( 'url' ); | |
$resources_title = $resources->field( 'title' ); | |
$resources_content = $resources->field( 'content' ); | |
?> | |
<div class="resource-item"> | |
<h3><a href="<?php echo $resources_url; ?>" target="_blank"><?php echo $resources_title; ?></a></h3> | |
<p><?php echo $resources_content; ?></p> | |
<a href="<?php echo $resources_url; ?>" target="_blank">Learn More</a> | |
</div> | |
<?php endwhile; ?> | |
</div> | |
<?php endif; | |
endwhile; | |
endif; | |
?> | |
</main><!-- #main --> | |
<div class="section-nav columns medium-4"> | |
<div class="section-nav-contain"> | |
<?php | |
$params = array( | |
'limit' => -1, | |
'expires' => 0 | |
); | |
$resource_category->find( $params ); | |
if ( 0 < $resource_category->total() ) : ?> | |
<h3>Jump to a Section</h3> | |
<ul> | |
<?php while ( $resource_category->fetch() ) : ?> | |
<li><a href="#<?php echo $resource_category->field( 'slug' );?>"><?php echo $resource_category->field( 'name' ); ?></a></li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> | |
<?php | |
$resources->find( array( 'limit' => -1, 'expires' => 0 ) ); | |
?> | |
<h3>A-Z Index</h3> | |
<ul> | |
<?php while ( $resources->fetch() ) : ?> | |
<li><a href="<?php echo $resources->field( 'url' );?>" target="_blank"><?php echo $resources->field( 'title' ); ?></a></li> | |
<?php endwhile; ?> | |
</ul> | |
</div> | |
</div> | |
</div><!-- #primary --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment