improved vars

This commit is contained in:
Joshua Perry 2023-01-23 16:44:56 +00:00
parent b9a479f0b4
commit d68eb37381
1 changed files with 16 additions and 7 deletions

View File

@ -3,16 +3,18 @@ namespace jobs\controllers;
class Jobs { class Jobs {
private $jobsTable; private $jobsTable;
private $catsTable; private $catsTable;
private $vars = [];
public function __construct(\CSY2028\DatabaseTable $jobsTable, \CSY2028\DatabaseTable $catsTable) { public function __construct(\CSY2028\DatabaseTable $jobsTable, \CSY2028\DatabaseTable $catsTable) {
$this->jobsTable = $jobsTable; $this->jobsTable = $jobsTable;
$this->catsTable = $catsTable; $this->catsTable = $catsTable;
$this->vars['cats'] = $this->catsTable->findAll();
} }
public function home() { public function home() {
return ['template' => 'home.html.php', return ['template' => 'home.html.php',
'title' => 'Jo\'s Jobs- Home', 'title' => 'Jo\'s Jobs- Home',
'vars' => ['cats' => $this->catsTable->findAll()] 'vars' => $this->vars
]; ];
} }
@ -22,20 +24,27 @@ class Jobs {
return $this->notFound(); return $this->notFound();
} }
else { else {
$this->vars['jobs'] = $this->jobsTable->find('categoryId', $cat[0]->id);
$this->vars['heading'] = $cat[0]->name;
return ['template' => 'category.html.php', return ['template' => 'category.html.php',
'title' => 'Jo\'s Jobs- '. $_GET['page'], 'title' => 'Jo\'s Jobs- '. $_GET['page'],
'vars' => ['jobs' => $this->jobsTable->find('categoryId', $cat[0]->id), 'vars' => $this->vars
'cats' => $this->catsTable->findAll(), ];
'heading' => $cat[0]->name]
];
} }
} }
public function about() {
return ['template' => 'about.html.php',
'title' => 'Jo\'s Jobs- About us',
'vars' => $this->vars
];
}
public function notFound() { public function notFound() {
return ['template' => 'notFound.html.php', return ['template' => 'notFound.html.php',
'title' => 'Jo\'s Jobs- 404 Not Found', 'title' => 'Jo\'s Jobs- 404 Not Found',
'vars' => [] 'vars' => $this->vars
]; ];
} }
} }
?> ?>