File: /var/www/vhosts/greenclinic.kz/newsite/wp-content/themes/green-clinic/single-doctors.php
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package asds
*/
//$categories = get_the_category( $the_post );
//$categories_name = $categories[0]->name;
//$categories_id = $categories[0]->term_id;
//$categories_slug = $categories[0]->slug;
$the_post = get_the_ID();
$theme_uri = get_template_directory_uri();
get_header();
?>
<?php get_template_part( 'template-parts/content_header', 'none' ); ?>
<?php
$name = get_field('name', FALSE, FALSE);
$speciality = get_field('speciality');
$specialization = get_field('specialization');
$experience = get_field('experience');
$inte = get_field('International');
$photo = get_field('photo');
$btn_show = get_field( 'btn_show');
if(empty($photo)){
$photo = '/wp-content/uploads/2024/02/doctor.webp';
}
$about_doc = get_field('about_doc');
/*echo '<pre>';
var_dump($photo);
echo '</pre>';*/
?>
<?php while(have_posts()): the_post(); ?>
<section class="section doctor <?php if($inte == 1): ?>supervisory<?php endif; ?>">
<div class="container">
<div class="doctor__container">
<div class="doctor__card">
<img id="img" src="" alt="" />
<?php if($btn_show == 0): ?>
<?php if($inte == 0): ?>
<a href="#">
<div class="doctor__card-button">
<button data-doc-name="<?php echo $name ?>">
<?php
// Get the current language
$current_language = wpm_get_language();
// Output the appropriate translation based on the current language
if ($current_language == 'ru') {
echo ' Записаться онлайн';
} elseif ($current_language == 'kz') {
echo 'Онлайн жазылу';
} else {
echo 'Sign up online'; // Default to Russian or the original language
}
?>
</button>
</div>
</a>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="doctor__info">
<h1 class="doctor__info-name" id="name"></h1>
<p class="doctor__info-position" id="position"></p>
<div class="doctor__info-experience">
<h2 id="experience"></h2>
<?php if($inte == 0): ?><p>
<?php
// Get the current language
$current_language = wpm_get_language();
// Output the appropriate translation based on the current language
if ($current_language == 'en') {
echo 'Experience';
} elseif ($current_language == 'kz') {
echo 'Еңбек өтілі';
} else {
echo 'Стаж'; // Default to Russian or the original language
}
?>
</p><?php endif; ?>
</div>
<?php if($specialization == true): ?><h3 class="doctor__info-specialization">
<?php
// Get the current language
$current_language = wpm_get_language();
// Output the appropriate translation based on the current language
if ($current_language == 'en') {
echo 'Specialty';
} elseif ($current_language == 'kz') {
echo 'Мамандығы';
} else {
echo 'Специализация'; // Default to Russian or the original language
}
?>
</h3><?php endif; ?>
<div class="doctor__info-specializatons" id="specializations"></div>
<?php if($inte == 0): ?><h2 class="doctor__info-about">
<?php
// Get the current language
$current_language = wpm_get_language();
// Output the appropriate translation based on the current language
if ($current_language == 'en') {
echo 'About Physician';
} elseif ($current_language == 'kz') {
echo 'Дәрігер туралы';
} else {
echo 'О враче'; // Default to Russian or the original language
}
?>
</h2><?php endif; ?>
<div
class="doctor__info-description first-description"
id="description"
><?php echo $about_doc ?></div>
</div>
</div>
</div>
</section>
<?php endwhile; ?>
<script>
const id = 1;
const doctors = [
{
id: 1,
imgSrc:
"<?php echo $photo ?>",
name: "<?php echo $name ?>",
position: "<?php echo $speciality ?>",
experience: "<?php echo $experience ?>",
specializations: [
<?php foreach($specialization as $spt_item):?>
"<?php echo $spt_item->name; ?>",
<?php endforeach;?>
],
description:
'',
},
];
const doctorImg = document.getElementById("img");
const doctorName = document.getElementById("name");
const doctorPosition = document.getElementById("position");
const doctorExperience = document.getElementById("experience");
const doctorSpecializations = document.getElementById("specializations");
const doctorDescription = document.getElementById("description");
doctorSpecializations.innerHTML = "";
doctors.map((doctor) => {
if (doctor.id === id) {
doctorImg.src = doctor.imgSrc;
doctorName.textContent = doctor.name;
doctorPosition.textContent = doctor.position;
doctorExperience.textContent = doctor.experience;
doctor.specializations.map((spec) => {
let docSpec = `
<div class="doctor__info-spec">
<span>${spec}</span>
</div>
`;
doctorSpecializations.innerHTML += docSpec;
});
}
});
</script>
<?php get_template_part( 'blocks/blocks' ); ?>
<?php get_footer(); ?>