- Created Find a Trainer page with interactive map and trainer directory - Integrated MapGeo plugin for displaying 45+ geocoded trainer locations - Built advanced filtering system (State/Province, Business Type, Training Format, Training Resources) - Implemented trainer profile cards with View Profile and See Events buttons - Added contact form handler with validation and email notifications - Created database table for tracking contact submissions - Responsive design with mobile-friendly layout - AJAX-powered search and filter functionality - Pagination support for trainer directory - Call to action for trainer registration Technical Implementation: - HVAC_Find_Trainer_Page: Main page handler with custom template - HVAC_MapGeo_Integration: Map marker management for trainer locations - HVAC_Contact_Form_Handler: Form processing with rate limiting - HVAC_Trainer_Directory_Query: Advanced querying with caching - HVAC_Contact_Submissions_Table: Database operations for submissions Tested with existing 53 trainer profiles, 45 geocoded locations Page live at: /find-a-trainer/ Co-Authored-By: Ben Reed <ben@tealmaker.com>
213 lines
No EOL
9 KiB
PHP
213 lines
No EOL
9 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Find a Trainer
|
|
* Template for displaying the Find a Trainer page
|
|
*
|
|
* @package HVAC_Plugin
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
// Define constant to identify we're in a page template
|
|
define('HVAC_IN_PAGE_TEMPLATE', true);
|
|
|
|
// Get header
|
|
get_header();
|
|
|
|
// Initialize required classes
|
|
if (class_exists('HVAC_Find_Trainer_Page')) {
|
|
$find_trainer = HVAC_Find_Trainer_Page::get_instance();
|
|
}
|
|
|
|
if (class_exists('HVAC_Trainer_Directory_Query')) {
|
|
$directory_query = HVAC_Trainer_Directory_Query::get_instance();
|
|
}
|
|
|
|
// Get trainers for initial display
|
|
$trainers_data = $directory_query ? $directory_query->get_trainers(['per_page' => 12]) : ['trainers' => [], 'total' => 0, 'pages' => 1];
|
|
$trainers = $trainers_data['trainers'];
|
|
$total_pages = $trainers_data['pages'];
|
|
|
|
// Enqueue required scripts and styles
|
|
wp_enqueue_style('hvac-find-trainer', HVAC_PLUGIN_URL . 'assets/css/find-trainer.css', [], HVAC_VERSION);
|
|
wp_enqueue_script('hvac-find-trainer', HVAC_PLUGIN_URL . 'assets/js/find-trainer.js', ['jquery'], HVAC_VERSION, true);
|
|
|
|
// Localize script with necessary data
|
|
wp_localize_script('hvac-find-trainer', 'hvac_find_trainer', [
|
|
'ajax_url' => admin_url('admin-ajax.php'),
|
|
'nonce' => wp_create_nonce('hvac_find_trainer'),
|
|
'map_id' => '5872',
|
|
'messages' => [
|
|
'loading' => __('Loading...', 'hvac'),
|
|
'error' => __('An error occurred. Please try again.', 'hvac'),
|
|
'no_results' => __('No trainers found matching your criteria.', 'hvac'),
|
|
'form_error' => __('Please check the form and try again.', 'hvac'),
|
|
'form_success' => __('Your message has been sent! Check your inbox for more details.', 'hvac')
|
|
]
|
|
]);
|
|
|
|
?>
|
|
|
|
<div class="hvac-find-trainer-wrapper ast-container">
|
|
|
|
<!-- Introduction Section -->
|
|
<div class="hvac-find-trainer-intro">
|
|
<h1>Find a Trainer</h1>
|
|
<p>Find certified HVAC trainers in your area. Use the interactive map and filters below to discover trainers who match your specific needs. Click on any trainer to view their profile and contact them directly.</p>
|
|
</div>
|
|
|
|
<!-- Map and Filter Section -->
|
|
<div class="hvac-map-filter-section">
|
|
|
|
<!-- Map Container -->
|
|
<div class="hvac-map-container">
|
|
<?php
|
|
// Check if MapGeo plugin is active and display map
|
|
if (shortcode_exists('display-map')) {
|
|
echo do_shortcode('[display-map id="5872"]');
|
|
} else {
|
|
// Fallback: Display a placeholder or static map
|
|
?>
|
|
<div class="hvac-map-placeholder">
|
|
<p>Interactive map coming soon</p>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
<!-- Filter Sidebar -->
|
|
<div class="hvac-filter-sidebar">
|
|
<div class="hvac-filter-controls">
|
|
<input type="text" class="hvac-search-input" placeholder="Search trainers..." aria-label="Search trainers">
|
|
|
|
<div class="hvac-filter-label">Filters:</div>
|
|
|
|
<button class="hvac-filter-button" data-filter="state" aria-label="Filter by State or Province">
|
|
<span class="hvac-filter-icon">▼</span> State / Province
|
|
</button>
|
|
|
|
<button class="hvac-filter-button" data-filter="business_type" aria-label="Filter by Business Type">
|
|
<span class="hvac-filter-icon">▼</span> Business Type
|
|
</button>
|
|
|
|
<button class="hvac-filter-button" data-filter="training_format" aria-label="Filter by Training Format">
|
|
<span class="hvac-filter-icon">▼</span> Training Format
|
|
</button>
|
|
|
|
<button class="hvac-filter-button" data-filter="training_resources" aria-label="Filter by Training Resources">
|
|
<span class="hvac-filter-icon">▼</span> Training Resources
|
|
</button>
|
|
|
|
<div class="hvac-active-filters"></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Trainer Directory Grid -->
|
|
<div class="hvac-trainer-directory">
|
|
<div class="hvac-trainer-grid">
|
|
<?php if (!empty($trainers)) : ?>
|
|
<?php foreach ($trainers as $trainer) : ?>
|
|
<div class="hvac-trainer-card" data-profile-id="<?php echo esc_attr($trainer['profile_id']); ?>">
|
|
<div class="hvac-trainer-card-inner">
|
|
<div class="hvac-trainer-avatar">
|
|
<?php if (!empty($trainer['profile_image'])) : ?>
|
|
<img src="<?php echo esc_url($trainer['profile_image']); ?>" alt="<?php echo esc_attr($trainer['name']); ?>">
|
|
<?php else : ?>
|
|
<div class="hvac-default-avatar">
|
|
<span><?php echo esc_html(substr($trainer['name'], 0, 1)); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="hvac-trainer-info">
|
|
<h3 class="trainer-name">
|
|
<a href="#" class="hvac-view-profile" data-profile-id="<?php echo esc_attr($trainer['profile_id']); ?>">
|
|
<?php echo esc_html($trainer['name']); ?>
|
|
</a>
|
|
</h3>
|
|
|
|
<p class="trainer-location">
|
|
<?php echo esc_html($trainer['city']); ?>, <?php echo esc_html($trainer['state']); ?>
|
|
</p>
|
|
|
|
<?php if (!empty($trainer['certification_type'])) : ?>
|
|
<p class="trainer-certification">
|
|
<?php echo esc_html($trainer['certification_type']); ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
|
|
<div class="hvac-trainer-actions">
|
|
<button class="hvac-view-profile hvac-btn-secondary" data-profile-id="<?php echo esc_attr($trainer['profile_id']); ?>">
|
|
View Profile
|
|
</button>
|
|
<?php if (!empty($trainer['upcoming_events'])) : ?>
|
|
<button class="hvac-see-events" data-profile-id="<?php echo esc_attr($trainer['profile_id']); ?>">
|
|
<span class="dashicons dashicons-calendar-alt"></span> Events (<?php echo count($trainer['upcoming_events']); ?>)
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else : ?>
|
|
<div class="hvac-no-results">
|
|
<p>No trainers found. Please try adjusting your filters.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php if ($total_pages > 1) : ?>
|
|
<div class="hvac-pagination">
|
|
<?php
|
|
echo paginate_links([
|
|
'total' => $total_pages,
|
|
'current' => 1,
|
|
'prev_text' => '« Previous',
|
|
'next_text' => 'Next »'
|
|
]);
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- Call to Action Section -->
|
|
<div class="hvac-trainer-cta">
|
|
<p>Are you an HVAC Trainer that wants to be listed in our directory?</p>
|
|
<a href="/trainer-registration/" class="button hvac-become-trainer-btn">Become a Trainer</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Filter Modal -->
|
|
<div class="hvac-filter-modal-overlay" style="display: none;">
|
|
<div class="hvac-filter-modal">
|
|
<div class="hvac-filter-modal-header">
|
|
<h3 class="hvac-filter-modal-title"></h3>
|
|
<button class="hvac-filter-modal-close">×</button>
|
|
</div>
|
|
<div class="hvac-filter-modal-body">
|
|
<div class="hvac-filter-options"></div>
|
|
</div>
|
|
<div class="hvac-filter-modal-footer">
|
|
<button class="hvac-filter-cancel">Cancel</button>
|
|
<button class="hvac-filter-apply">Apply Filter</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Trainer Profile Modal -->
|
|
<div class="hvac-trainer-modal-overlay" style="display: none;">
|
|
<div class="hvac-trainer-modal" role="dialog" aria-labelledby="trainer-modal-title" aria-modal="true">
|
|
<div class="hvac-trainer-modal-content">
|
|
<!-- Content will be loaded here via AJAX -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
// Get footer
|
|
get_footer();
|
|
?>
|