Youcef Developer
4/30/2019 - 3:02 PM

Pubmatic Project

<!-- archive-products.php -->
<?php get_header(); ?>

<!-- BANNER AND NAVIGATION -->
<?php 
$currentLang = 'en';
if (function_exists('pll_current_language')) {
	$currentLang = isset($_COOKIE['preferredlang']) ? $_COOKIE['preferredlang'] : pll_current_language();
}

// TODO - REMOVE IT WHEN THE NEW TEMPLATE GOES LIVE
$tpl = isset($_GET['tpl']) ? $_GET['tpl'] : '';
?>

<?php 
	// TODO - REMOVE THE IF BLOCK WHEN THE NEW TEMPLATE GOES LIVE
	if ($tpl != 'new') { // OLD TEMPLATE ?>

	<?php
		$bannerImage        = get_field('products_image', $currentLang);
		$bannerHeading      = get_field('products_heading', $currentLang);
		$bannerSubheading   = get_field('products_subheading', $currentLang);
		$bannerCopyPosition = get_field('products_copy_position', $currentLang);
		$transparentNav = ($bannerImage) ? true : false;
		include(locate_template('parts/navigation.php'));
	?>

	<div class="main <?= ($transparentNav) ? 'main-collapse-top' : '' ?> products">
		<?php if ($bannerImage) { ?>
			<div class="banner" <?= empty($bannerImage) ? '' : "style=\"background-image: url({$bannerImage})\"" ?> >
				<div class="content-<?= strtolower($bannerCopyPosition)?>">
					<div class="container hidden-xs">
						<div class="row">
							<div class="col-md-6">
								<h1 class="display-1 text-uppercase"><?= $bannerHeading ?></h1>
							</div>
						</div>
						
						<div class="row">
							<div class="col-md-6">
								<div class="lead"><?= $bannerSubheading ?></div>
							</div>
						</div>	
					</div> 
				</div> 
			</div>
			<div class="container hidden-sm hidden-md hidden-lg">
				<div class="row">
					<div class="col-md-6">
						<h1 class="display-1 text-uppercase"><?= $bannerHeading ?></h1>
					</div>
				</div>
				
				<div class="row">
					<div class="col-md-6">
						<div class="lead"><?= $bannerSubheading ?></div>
					</div>
				</div>
			</div>
		<?php } ?>


		<div class="container">
		
			<div class="section-header">
				<h3>
					<!-- translation -->
					<?= ($currentLang == 'en') ? 'OUR PRODUCTS' : '製品' ?>
				</h3>
			</div>
			<div class="products-description lead"><?= get_field('products_lead_text', $currentLang) ?></div>
		
			<!-- featured product -->	
			<section>
				<?php
				
				if (have_posts()){
					while (have_posts()){
						the_post();
						if (get_field('featured')) { 
							?>
							<div class="well">
								<div class="row">
									<div class="col-md-12">
										<span class="dash"></span>
									</div>
								</div>
								<div class="row" data-align-height=".vertical-divider">
									<div class="col-sm-6 vertical-divider">
										<div class="featured">
											<div class="heading">
												<div class="h1 text-uppercase"><a href="<?= the_permalink(); ?>" class="black-link"><?= the_title(); ?></a></div>
											</div>
											<div class="body">
												<p class="lead"><?= get_field('featured_description'); ?></p>
											</div>
											<div class="link">
												<a href="<?= the_permalink(); ?>" class="btn btn-primary">
													<!-- translation -->
													<?= ($currentLang == 'en') ? 'READ MORE' : '詳細はこちら'?>
												</a>&nbsp;&nbsp;
											</div>
										</div>
									</div>
									<div class="col-sm-6 vertical-divider">
										<p><?= the_excerpt(); ?></p>
									</div>
								</div>
							</div>
							<?php
						}
					}?>
					
				<?php
				}
				rewind_posts();
			?>
			</section>
			
			
			<?php if (have_posts()) { ?>
				<section>
					<div class="row-divider">
						<div class="row">
							<?php 
							$counter = 0;
							while (have_posts()) { 
								the_post(); 
								if (!get_field('featured')) {
									$preview = get_field('preview');
									$counter++;
									echo ($counter % 2 == 1 ) ? '</div></div><div class="row-divider"><div class="row" data-align-height=".heading, .body, .featured">' : "" ;?>	
									<div class="col-md-6 vertical-divider">
										<div class="featured">
											<div class="image">
											<?php if (!empty($preview)) { ?>
												<a href="<?= the_permalink(); ?>" class="black-link"><img src="<?= $preview['sizes']['large'] ?>" class="img-responsive center-block" /></a>
											<?php } ?>
											</div>
											<div class="heading">
												<h3><a href="<?= the_permalink(); ?>" class="black-link"><?php the_title(); ?></a></h3>
											</div>
											<div class="body">
												<a href="<?= the_permalink(); ?>" class="black-link"><?php the_excerpt(); ?></a>
											</div>
											<div class="link">
												<a href="<?php the_permalink(); ?>">
													<!-- translation -->
													<?= ($currentLang == 'en') ? 'READ MORE' : '詳細はこちら'?>
												</a>
											</div>
										</div>
									</div>
							<?php } 
							} ?>
						</div>
					</div>
				</section>
			<?php } ?>
			
		</div>
	</div>

<?php } else { // NEW TEMPLATE ?>
	
	<?php 
		$fields = get_fields($currentLang);
		$transparentNav = (!empty($fields['hero']['hero_slides'])) ? true : false; 
	?>

	<div class="main bg-light products-archive <?= ($transparentNav) ? 'main-collapse-top' : ''; ?>">

		<?php include(locate_template('parts/navigation.php')) ?>
		
		<?php include(locate_template('parts/new-hero.php')); ?>

		<div class="container">
		
			<div class="section-header">
				<h3>
					<!-- translation -->
					<?= ($currentLang == 'en') ? 'OUR PRODUCTS' : '製品' ?>
				</h3>
			</div>
			<div class="products-description lead"><?= get_field('products_lead_text', $currentLang) ?></div>
		
			<!-- featured product -->	
			<section>
				<?php
				
				if (have_posts()){
					while (have_posts()){
						the_post();
						if (get_field('featured')) { 
							?>
							<div class="well">
								<div class="row">
									<div class="col-md-12">
										<span class="dash"></span>
									</div>
								</div>
								<div class="row" data-align-height=".vertical-divider">
									<div class="col-sm-6 vertical-divider">
										<div class="featured">
											<div class="heading">
												<div class="h1 text-uppercase"><a href="<?= the_permalink(); ?>" class="black-link"><?= the_title(); ?></a></div>
											</div>
											<div class="body">
												<p class="lead"><?= get_field('featured_description'); ?></p>
											</div>
											<div class="link">
												<a href="<?= the_permalink(); ?>" class="btn btn-primary">
													<!-- translation -->
													<?= ($currentLang == 'en') ? 'READ MORE' : '詳細はこちら'?>
												</a>&nbsp;&nbsp;
											</div>
										</div>
									</div>
									<div class="col-sm-6 vertical-divider">
										<p><?= the_excerpt(); ?></p>
									</div>
								</div>
							</div>
							<?php
						}
					}?>
					
				<?php
				}
				rewind_posts();
			?>
			</section>
			
			
			<?php if (have_posts()) { ?>
				<section>
					<div class="row-divider">
						<div class="row">
							<?php 
							while (have_posts()) { 
								the_post(); 
								if (!get_field('featured')) {
									$preview = get_field('icon');
									?>

									<div class="col-sm-6 col-md-4 text-center">
										<div class="inlaid-card inlaid-card-gap bg-white" data-mh="inlaid-card">
											<div class="inlaid-image" data-mh="inlaid-card-img">
												<?= wp_get_attachment_image($preview, 'full', false, ['class' => 'img-responsive']) ?>
											</div>
											<p class="inlaid-title" data-mh="inlaid-card-title"><?php the_title(); ?></p>
											<p class="inlaid-description" data-mh="inlaid-card-desc">
												<?= ($currentLang == 'en') ? get_the_excerpt() : jp_excerpt(200) ?>		
											</p>
											<a href="<?php the_permalink(); ?>" class="btn btn-outline">
												<!-- translation -->
												<?= ($currentLang == 'en') ? 'LEARN MORE' : '詳細はこちら'?>
											</a>
										</div>
									</div>

							<?php } 
							} ?>
						</div>
					</div>
				</section>
			<?php } ?>
			
		</div>
	</div>

<?php } ?>

<?php get_footer(); ?>