Commit 12611fef by rajshah

fix the xls document type in resource listing block

parent 912412bf
...@@ -6,47 +6,47 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc ...@@ -6,47 +6,47 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc
if ($enable_resources_listing): if ($enable_resources_listing):
$resources_items = $resources_listing['resources_items'] ?: []; $resources_items = $resources_listing['resources_items'] ?: [];
if (isset($resources_items) && is_array($resources_items) && !empty($resources_items)): if (isset($resources_items) && is_array($resources_items) && !empty($resources_items)):
?> ?>
<section class="resource-listing py-80 makura-new"> <section class="resource-listing py-80 makura-new">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-lg-4 col-xl-3"> <div class="col-lg-4 col-xl-3">
<div class="toc slide-up"> <div class="toc slide-up">
<div class="toc-title"> <div class="toc-title">
<h6>Table of Content</h6> <h6>Table of Content</h6>
</div> </div>
<div class="category-list"> <div class="category-list">
<ul> <ul>
<?php foreach ($resources_items as $ri => $res_item): <?php foreach ($resources_items as $ri => $res_item):
$title = $res_item['title'] ?: ''; $title = $res_item['title'] ?: '';
?> ?>
<li class="<?php echo ($ri === 0) ? 'active' : ''; ?>"><a href="#" class="sm-text" <li class="<?php echo ($ri === 0) ? 'active' : ''; ?>"><a href="#" class="sm-text"
data-target="<?php echo strtolower(str_replace(' ', '-', $title)); ?>"><?php echo esc_html($title); ?></a> data-target="<?php echo strtolower(str_replace(' ', '-', $title)); ?>"><?php echo esc_html($title); ?></a>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
<div class="col-lg-8 col-xl-9"> <div class="col-lg-8 col-xl-9">
<div class="resource-wrapper"> <div class="resource-wrapper">
<?php foreach ($resources_items as $ri => $res_item): <?php foreach ($resources_items as $ri => $res_item):
$title = $res_item['title'] ?: ''; $title = $res_item['title'] ?: '';
$desc = $res_item['desc'] ?: ''; $desc = $res_item['desc'] ?: '';
$select_resources = $res_item['select_resources'] ?: []; $select_resources = $res_item['select_resources'] ?: [];
?> ?>
<div class="resource-block slide-up" id="<?php echo strtolower(str_replace(' ', '-', $title)); ?>"> <div class="resource-block slide-up" id="<?php echo strtolower(str_replace(' ', '-', $title)); ?>">
<div class="section-title"> <div class="section-title">
<?php if (!empty($title)): ?> <?php if (!empty($title)): ?>
<h2><?php echo $title; ?></h2><?php endif; ?> <h2><?php echo $title; ?></h2><?php endif; ?>
<?php if (!empty($desc)): <?php if (!empty($desc)):
echo $desc ?: ''; echo $desc ?: '';
endif; ?> endif; ?>
</div> </div>
<?php if (!empty($select_resources) && isset($select_resources) && is_array($select_resources)): ?> <?php if (!empty($select_resources) && isset($select_resources) && is_array($select_resources)): ?>
<div class="resources"> <div class="resources">
<div class="row"> <div class="row">
<?php foreach ($select_resources as $sel_res): <?php foreach ($select_resources as $sel_res):
if ($sel_res instanceof WP_Post) { if ($sel_res instanceof WP_Post) {
$post_id = $sel_res->ID; $post_id = $sel_res->ID;
$post_url = get_permalink($post_id); $post_url = get_permalink($post_id);
...@@ -57,25 +57,25 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc ...@@ -57,25 +57,25 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc
} }
$post_content = $sel_res->post_content; $post_content = $sel_res->post_content;
$post_excerpt = $sel_res->post_excerpt; $post_excerpt = $sel_res->post_excerpt;
?> ?>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="resource-item d-sm-flex flex-sm-column flex-xl-row justify-content-xl-start slide-up"> <div class="resource-item d-sm-flex flex-sm-column flex-xl-row justify-content-xl-start slide-up">
<div class="resource-image"> <div class="resource-image">
<a href="<?php echo esc_url($post_url); ?>" class="d-block"> <a href="<?php echo esc_url($post_url); ?>" class="d-block">
<img src="<?php echo esc_url($post_thumbnail_url); ?>" <img src="<?php echo esc_url($post_thumbnail_url); ?>"
alt="<?php echo esc_attr($post_title); ?>" class="img-fluid"> alt="<?php echo esc_attr($post_title); ?>" class="img-fluid">
</a> </a>
</div> </div>
<div class="resource-content"> <div class="resource-content">
<div class="rc-detail"> <div class="rc-detail">
<h6><a href="<?php echo esc_url($post_url); ?>"> <h6><a href="<?php echo esc_url($post_url); ?>">
<?php echo esc_html($post_title); ?></a></h6> <?php echo esc_html($post_title); ?></a></h6>
<P class="sm-text"> <P class="sm-text">
<?php echo wp_trim_words($post_excerpt, 8, '...') ?: wp_trim_words($post_content, 8, '...'); ?> <?php echo wp_trim_words($post_excerpt, 8, '...') ?: wp_trim_words($post_content, 8, '...'); ?>
</P> </P>
</div> </div>
<div class="format-and-btn-wrapper d-flex justify-content-between"> <div class="format-and-btn-wrapper d-flex justify-content-between">
<?php <?php
$downloadable_resource = get_field('downloadable_resource', $post_id) ?: []; $downloadable_resource = get_field('downloadable_resource', $post_id) ?: [];
if (isset($downloadable_resource) && is_array($downloadable_resource) && !empty($downloadable_resource)): if (isset($downloadable_resource) && is_array($downloadable_resource) && !empty($downloadable_resource)):
$enable_downloadable_resources = $downloadable_resource['enable_downloadable_resources']; $enable_downloadable_resources = $downloadable_resource['enable_downloadable_resources'];
...@@ -85,47 +85,50 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc ...@@ -85,47 +85,50 @@ if (isset($resources_listing) && is_array($resources_listing) && !empty($resourc
$subtype = $upload_downloadable_resource['subtype']; $subtype = $upload_downloadable_resource['subtype'];
switch (strtolower($subtype)) { switch (strtolower($subtype)) {
case 'pdf': case 'pdf':
$icon_url = get_field('pdf_image', 'option'); $icon = 'PDF';
break; break;
case 'doc': case 'doc':
case 'docx': case 'docx':
$icon_url = get_field('doc_image', 'option'); $icon = 'DOC';
break; break;
case 'xls': case 'xls':
case 'xlsx': case 'xlsx':
case 'vnd.ms-excel': case 'vnd.ms-excel':
case 'vnd.openxmlformats-officedocument.spreadsheetml.sheet': case 'vnd.openxmlformats-officedocument.spreadsheetml.sheet':
$icon_url = get_field('xls_image', 'option'); $icon = 'XLS';
break; break;
case 'ppt': case 'ppt':
case 'pptx': case 'pptx':
case 'vnd.openxmlformats-officedocument.presentationml.presentation': case 'vnd.openxmlformats-officedocument.presentationml.presentation':
$icon_url = get_field('ppt_image', 'option'); $icon = 'PPT';
break; break;
default: default:
$icon_url = get_field('default_image', 'option'); $icon = 'PDF';
} }
endif; endif;
endif; endif;
?> ?>
<p class="sm-text">Format: <img src="<?php echo esc_url($icon_url); ?>" <p class="sm-text">Format: <img src="<?php echo esc_url($icon_url); ?>"
alt="<?php echo esc_attr($subtype); ?>"></p> alt="<?php echo esc_attr($subtype); ?>"></p>
<a href="<?php echo esc_url($post_url); ?>" class="mc-btn-underlined sm-text">View in <a href="<?php echo esc_url($post_url); ?>" class="mc-btn-underlined sm-text">View in
Detail</a> Detail</a>
</div>
</div>
</div>
</div>
<?php }
endforeach; ?>
</div>
</div> </div>
</div> <?php endif; ?>
</div> </div>
</div> <?php endforeach; ?>
<?php }endforeach; ?>
</div> </div>
</div> </div>
<?php endif; ?>
</div> </div>
<?php endforeach; ?>
</div> </div>
</div> </section>
</div> <?php endif;
</div> endif;
</section> endif; ?>
<?php endif; endif; endif; ?>
<!-- !Resources - Resources Listing --> <!-- !Resources - Resources Listing -->
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment