<?php
/*
 Template Name: Materials children Page
 */ 
?>
<?php get_header(); ?>

			<div id="content">

				<div id="inner-content" class="wrap cf">
					<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
						<main id="main" class="no-widgets-main m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog">
							<?php $products = new WP_Query( 'pagename=materials' );?>

							
							<?php while ($products->have_posts()) : $products->the_post(); ?>
								<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf home-article' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
								<section class="entry-content cf" itemprop="articleBody">
									<div class="home-content">
									<?php
										// the content (pretty self explanatory huh)
										the_content();
										/*
										 * Link Pages is used in case you have posts that are set to break into
										 * multiple pages. You can remove this if you don't plan on doing that.
										 *
										 * Also, breaking content up into multiple pages is a horrible experience,
										 * so don't do it. While there are SOME edge cases where this is useful, it's
										 * mostly used for people to get more ad views. It's up to you but if you want
										 * to do it, you're wrong and I hate you. (Ok, I still love you but just not as much)
										 *
										 * http://gizmodo.com/5841121/google-wants-to-help-you-avoid-stupid-annoying-multiple-page-articles
										 *
										*/
										wp_link_pages( array(
											'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'bonestheme' ) . '</span>',
											'after'       => '</div>',
											'link_before' => '<span>',
											'link_after'  => '</span>',
										) );
									?>
									</div>
								<?php endwhile; ?>
								<?php wp_reset_postdata(); ?>
									<div class="ghost-image">
										<?php if ( has_post_thumbnail()): // check if the post has a Post Thumbnail assigned to it.
											echo get_the_post_thumbnail( get_the_ID(), "full", array ('class' => 'box-image')); 
									//wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID(), 'full') );; ?>
									<?php endif; ?>
									</div>
									</section>
									</article>
							<div class="left-menu">
								<ul class="left-main-menu">
									<li><a href="#" class="left-sub-menu-container">Products </a>
									<?php $products= new WP_Query( 'pagename=products' );?>

							
									<?php while ($products->have_posts()) : $products->the_post(); ?>
									<?php $products_id=get_the_ID(); ?>
									<?php endwhile; ?>
									<?php wp_reset_postdata(); ?>
									<ul class="left-sub-menu">
										<?php $args = array(
											'sort_order' => 'asc',
											'sort_column' => 'post_title',
											'parent' => $products_id,
											'post_type' => 'page',
											'post_status' => 'publish'
										); 
										$prods = get_pages($args); 
										?>
										<?php foreach ( $prods as $page ) { ?>
											<li><a href="<?php echo get_page_link($page->ID);?>"><?php echo $page->post_title?></a></li>
										<?php } ?>
									</ul>
									</li>
									<li><a href="#" class="left-sub-menu-container">Materials </a>
									<?php $materials= new WP_Query( 'pagename=materials' );?>

							
									<?php while ($materials->have_posts()) : $materials->the_post(); ?>
									<?php $materials_id=get_the_ID(); ?>
									<?php endwhile; ?>
									<?php wp_reset_postdata(); ?>
									<ul class="left-sub-menu">
										<?php $args = array(
											'sort_order' => 'asc',
											'sort_column' => 'post_title',
											'parent' => $materials_id,
											'post_type' => 'page',
											'post_status' => 'publish'
										); 
										$mats = get_pages($args); 
										?>
										<?php foreach ( $mats as $page ) { ?>
											<li><a href="<?php echo get_page_link($page->ID);?>"><?php echo $page->post_title?></a></li>
										<?php } ?>
									</ul>
									</li>
								</ul>
							</div>

							<article id="post-<?php the_ID(); ?>" <?php post_class( 'cf striped-article' ); ?> role="article" itemscope itemtype="http://schema.org/BlogPosting">
								<section class="entry-content cf" itemprop="articleBody">
									<div class="products-content">
										<div role="tabpanel">

										  <!-- Nav tabs -->
										  <ul class="nav nav-tabs" role="tablist">
											<li role="presentation" class="active"><a href="#overview" aria-controls="overview" role="tab" data-toggle="tab">Overview</a></li>
											<li role="presentation"><a href="#properties" aria-controls="properties" role="tab" data-toggle="tab">Properties</a></li>
										  </ul>

										  <!-- Tab panes -->
										  <div class="tab-content">
											<div role="tabpanel" class="tab-pane active" id="overview"><?php the_content();?></div>
											<div role="tabpanel" class="tab-pane" id="properties"><?php the_field('properties');;?></div>
										  </div>

										</div>
									<?php
										wp_link_pages( array(
											'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'bonestheme' ) . '</span>',
											'after'       => '</div>',
											'link_before' => '<span>',
											'link_after'  => '</span>',
										) );
									?>
									</div>
									<!--<div class="ghost-image">
										<img src="<?php echo get_template_directory_uri();?>/img/ghost-images-products.jpg" />
									</div>-->
								</section> <?php // end article section ?>

								<footer class="article-footer cf">

								</footer>

							</article>

							<?php endwhile; endif; ?>

						</main>

				</div>

			</div>

<?php get_footer(); ?>
