Made a start on this today.
Firstly, add into /admin/_templates/header.tpl:
Code:<li><a {if $CURRENT_PAGE == ''}class="selected"{/if} href="{$BASE_URL_ADMIN}">Inactive jobs</a></li>
<li><a {if $CURRENT_PAGE == 'active-jobs'}class="selected"{/if} href="{$BASE_URL_ADMIN}active-jobs">Active jobs</a></li>
So what I've done there is changed "Home" to "Inactive jobs" (just for clarity) and added the second line which makes a menu link to our new "Active jobs" page.
in /admin/_templates/header.tpl, add:
Code: case 'active-jobs':
if(!isset($_SESSION['AdminId']))
{
redirect_to(BASE_URL);
exit;
}
require_once 'page_jobs_active.php';
$flag = 1;
break;
somewhere in the $page switch. I added it after case 'home': just cos the order made sense.
Now create a new page, admin/page_jobs_active.php, with the following contents:
Code:<?php
$the_jobs = array();
$jobCount = $job->getActiveJobCount();
$paginator = new Paginator($jobCount, JOBS_PER_PAGE, @$_REQUEST['p']);
$paginator->setLink(BASE_URL.'home');
$paginator->paginate();
$firstLimit = $paginator->getFirstLimit();
$lastLimit = $paginator->getLastLimit();
$the_jobs = $job->GetPaginatedJobs($firstLimit, JOBS_PER_PAGE);
$smarty->assign("pages",$paginator->pages_link);
$smarty->assign('jobs', $the_jobs);
$template = 'index-active.tpl';
?>
This is based on the page_home.php file which obviously is the one that shows the Inactive jobs.
There isn't much I've changed, only three bits: getInactiveJobCount() has become getActiveJobCount(), GetInactiveJobs has become GetPaginatedJobs, and index.tpl has become index-active.tpl.
Time for another new file, the new template. Create a copy of admin/_templates/index.tpl and name it index-active.tpl (as above). All you need to change in this one is change the <h2> title from "Inactive jobs" to "Active jobs".
Now to add the new function that we call in page_jobs_active.php. Add this code to _includes/class.Job.php:
Code: public function getActiveJobCount()
{
global $db;
$sql = 'SELECT COUNT(id) AS total FROM '.DB_PREFIX.'jobs WHERE is_temp = 0 AND is_active = 1';
$result = $db->query($sql);
$row = $result->fetch_assoc();
return $row['total'];
}
This is just a copy of the getInactiveJobCount() function where we're querying the database for jobs with is_active = 1 rather than = 0.
So that's your lot - you'll now have a page for viewing ALL active jobs in the admin section, just like you have always had a page for inactive jobs.
It's not done though, and hopefully one of you (probably Puty!) can give me some help!
Problems:
- I don't think GetPaginatedJobs is the right function to call, it's not an equivalent to GetInactiveJobs where it probably needs to be. There's some other stuff that already deals with pagination in there so I don't know if the pagination is getting repeated.
- As such, I'm not sure if this will work properly when there is need for pagination. Can't test at the moment as my site only has 7 active jobs on at the moment.
- Additionally, and importantly, the posts-loop.tpl file is not displaying the details of applications on the job listings where I want it to be doing so. I know why these aren't being shown, because {if $statisticalData[$job.id]} does not return true, I just don't know why it isn't returning true.
Look forward to someone helping me build on this, and hope it's useful as a start point.