How to Use Templates?

Tables - 2 Parts

Part 1 -
Folder

ex - Nurse Salary
nurse-salary

Part 2 -
Maximum 4 location files:

  1. Country
  2. State
  3. District
  4. City


country.php

<?php
$country = App\Models\Location::activeCountry('IN');
$states = $country->states();
?>

<?= template()->layout('frontend/layout') ?>

<?= template()->push('meta') ?>
<title><?= $template->title ?></title>
<meta name="description" content="<?= $template->title ?>">
<?= template()->endPush() ?>

<div class="container py-5">
<article class="mb-5">
<h1 class="mb-3">
<?= $template->title ?>
<?= $country->name ?>
</h1>
<p>Country-specific template content would go here.</p>
</article>

<h2>States</h2>
<ul>
<?php foreach ($states as $state): ?>
<li>
<a href="<?= route()->url('frontend.templates.location', ['templateId' => $template->id, 'locationId' => $state->id]) ?>">
<?= $state->name ?>
</a>
</li>
<?php endforeach; ?>
</ul>

<!-- DEMONSTRATION: Recommended Listings (Similar by Tags) -->
<?php $recommendedListings = $template->recommendedListings(5); ?>
<?= template()->include('frontend/custom/jobs/partials/recommended-listings', [
'recommendedListings' => $recommendedListings
]) ?>

<!-- Recommended Blogs -->
<?php $recommendedBlogs = $template->recommendedBlogs(3); ?>
<?= template()->include('frontend/custom/jobs/partials/recommended-blogs', [
'recommendedBlogs' => $recommendedBlogs
]) ?>
</div>

state.php

<?= template()->layout('frontend/layout') ?>

<?= template()->push('meta') ?>
<title><?= $template->title ?></title>
<meta name="description" content="<?= $template->title ?>">
<?= template()->endPush() ?>

<div class="container py-5">
<article class="mb-5">
<h1 class="mb-3">
Hello: <?= $template->title ?> : <?= $state->name ?>
</h1>
<p>State-specific template content would go here.</p>
</article>

<h2>Districts</h2>
<ul>
<?php foreach ($state->districts() as $district): ?>
<li>
<a href="<?= route()->url('frontend.templates.location', ['templateId' => $template->id, 'locationId' => $district->id]) ?>">
<?= $district->name ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>

district.php

<?= template()->layout('frontend/layout') ?>

<?= template()->push('meta') ?>
<title><?= $template->title ?></title>
<meta name="description" content="<?= $template->title ?>">
<?= template()->endPush() ?>

<div class="container py-5">
<article class="mb-5">
<h1 class="mb-3">
<?= $template->title ?> : <?= $district->name ?>
</h1>
<p>District-specific template content would go here.</p>
</article>

<h2>Cities</h2>
<ul>
<?php foreach ($district->cities() as $city): ?>
<li>
<a href="<?= route()->url('frontend.templates.location', ['templateId' => $template->id, 'locationId' => $city->id]) ?>">
<?= $city->name ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>

city.php

<?= template()->layout('frontend/layout') ?>

<?= template()->push('meta') ?>
<title><?= $template->title ?></title>
<meta name="description" content="<?= $template->title ?>">
<?= template()->endPush() ?>

<div class="container py-5">
<article class="mb-5">
<h1 class="mb-3">
<?= $template->title ?> : <?= $city->name ?>
</h1>
<p>City-specific template content would go here.</p>
</article>
</div>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.