Tables - 2 Parts
Part 1 -
Folder
ex - jobsPart 2 -
Three Files
- data.php - contains data in array format.
- detail.php - individual tables - individual posts
number of tabels = number of array items.
ex - Branch Manager Salary in ICICI - show.php - main landing page of the table
ex - Bank Branch Salary in India
data.php
<?php
return [
[
'slug' => 'sde-1',
'name' => 'SDE 1',
'salary' => 120000,
'description' => 'Software Development Engineer 1'
],
[
'slug' => 'sde-2',
'name' => 'SDE 2',
'salary' => 150000,
'description' => 'Software Development Engineer 2'
],
[
'slug' => 'sde-3',
'name' => 'SDE 3',
'salary' => 200000,
'description' => 'Senior Software Development Engineer'
],
[
'slug' => 'pm',
'name' => 'Product Manager',
'salary' => 180000,
'description' => 'Product Manager with team leadership and budget responsibility'
],
[
'slug' => 'tech-lead',
'name' => 'Tech Lead',
'salary' => 250000,
'description' => 'Technical lead with team management and architecture responsibilities'
],
[
'slug' => 'cto',
'name' => 'CTO',
'salary' => 350000,
'description' => 'Chief Technology Officer with strategic leadership'
],
];
detail.php
<?php
$salaries = include __DIR__ . '/data.php';
$currentSalary = array_filter($salaries, function($salary) use ($slug) {
return $salary['slug'] === $slug;
})[0] ?? null;
if (!$currentSalary) {
halt(404);
}
?>
<?= template()->layout('frontend/layout') ?>
<?= template()->push('meta') ?>
<title><?= $currentSalary['name'] ?> - <?= $table->title ?></title>
<meta name="description" content="<?= $currentSalary['description'] ?>">
<?= template()->endPush() ?>
<h1><?= $currentSalary['name'] ?></h1>
<p><?= $currentSalary['description'] ?></p>
<p>Salary: $<?= number_format($currentSalary['salary']) ?></p>
show.php
<?php
$fruits = include __DIR__ . '/data.php';
?>
<?= template()->layout('frontend/layout') ?>
<?= template()->push('meta') ?>
<title>Table: <?= $table->title ?></title>
<meta name="description" content="All published tables displayed here">
<?= template()->endPush() ?>
<h1>Jobs <?= $table->title ?> 222222</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>Salary</th>
<th>Description</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($fruits as $fruit): ?>
<tr>
<td><?= $fruit['name'] ?></td>
<td>$<?= $fruit['salary'] ?></td>
<td><?= $fruit['description'] ?></td>
<td><a href="<?= route()->url('frontend.tables.detail', ['tableId' => $table->id, 'slug' => $fruit['slug']]) ?>">View</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- DEMONSTRATION: Recommended Listings (Similar by Tags) -->
<?php $recommendedListings = $table->recommendedListings(5); ?>
<?= template()->include('frontend/custom/jobs/partials/recommended-listings', [
'recommendedListings' => $recommendedListings
]) ?>
<!-- Recommended Blogs -->
<?php $recommendedBlogs = $table->recommendedBlogs(3); ?>
<?= template()->include('frontend/custom/jobs/partials/recommended-blogs', [
'recommendedBlogs' => $recommendedBlogs
]) ?>
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.