| @@ -5,9 +5,8 @@ | ||
| 5 | 5 | namespace Yatra\Core\Handlers; |
| 6 | 6 | |
| 7 | 7 | use Yatra\Controllers\SingleTripController; |
| 8 | 8 | use Yatra\Core\Assets\TripAssetManager; |
| 9 | -use Yatra\Core\Template\TemplateRenderer; | |
| 10 | 9 | use Yatra\Services\SettingsService; |
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Trip Page Handler |
| @@ -37,8 +36,17 @@ | ||
| 37 | 36 | // Set up global trip object for template compatibility |
| 38 | 37 | global $trip; |
| 39 | 38 | $trip = $trip_data; |
| 40 | 39 | |
| 40 | + // Configure $wp_query + virtual WP_Post so FSE block themes resolve the | |
| 41 | + // singular template (not 404.html) and render the site header normally. | |
| 42 | + $this->setupPageEnvironment('singular', [ | |
| 43 | + 'title' => (string) ($trip->title ?? $trip->name ?? ''), | |
| 44 | + 'object_id' => (int) ($trip->id ?? 0), | |
| 45 | + 'post_type' => 'page', | |
| 46 | + 'post_name' => $trip_slug, | |
| 47 | + ]); | |
| 48 | + | |
| 41 | 49 | // Set up query vars for backward compatibility |
| 42 | 50 | $this->setQueryVars([ |
| 43 | 51 | 'yatra_trip_id' => $trip->id, |
| 44 | 52 | 'yatra_trip' => $trip, |
| @@ -45,16 +53,7 @@ | ||
| 45 | 53 | 'yatra_trip_slug' => $trip_slug, |
| 46 | 54 | 'yatra_page' => $route_data['base'] ?? SettingsService::getTripBase(), |
| 47 | 55 | ]); |
| 48 | 56 | |
| 49 | - // Create asset manager and render template | |
| 50 | - $asset_manager = new TripAssetManager(); | |
| 51 | - $template_path = TemplateRenderer::getTemplatePath('single-trip'); | |
| 52 | - | |
| 53 | - // Render template with global $trip already set | |
| 54 | - if (!TemplateRenderer::render($template_path, [], $asset_manager)) { | |
| 55 | - return false; | |
| 56 | - } | |
| 57 | - | |
| 58 | - return true; | |
| 57 | + return $this->selectTemplate('single-trip', new TripAssetManager(), 'trip'); | |
| 59 | 58 | } |
| 60 | 59 | } |