Topic: Selectable "spotlight" jobs modification (for sponsored jobs etc.)
Important: This modification is now included from version 1.6 and newer, there is no need to follow this guide unless you run an earlier version!
This modification adds the ability to select jobs as 'spotlight jobs', which should be interesting for 'premium services' and such.
Features:
- Ability to enable/disable spotlight mode for jobs at the admin panel (much like normal enabling/disabling)
- Ability to filter on spotlight jobs with all the normal features as ammount of jobs, random list etc.
- See a working example on Telefonisch Werk
This modification changes a lot of files (mostly because of the admin panel feature), so backup your files!!
1. Alter db table:
ALTER TABLE `jobs` ADD `spotlight` TINYINT(4) default NULL AFTER `apply_online`;2. in "page_home.php":
Find:
$smarty->assign('latest_jobs', $job->GetJobs(0, 0, 7, 0, 0));Add below:
$smarty->assign('spotlight_jobs', $job->GetJobs(0, 0, 3, 1, 0, 0, 0, 0, 1));3. in "_includes/classJob.php":
Find:
$sql = 'SELECT a.type_id AS type_id, a.category_id AS category_id, a.title AS title, a.description AS description,
a.company AS company, a.url AS url, a.apply AS apply,
DATE_FORMAT(a.created_on, \'%d-%m-%Y\') AS created_on, a.created_on AS mysql_date,
a.is_temp AS is_temp, a.is_active AS is_active
a.views_count AS views_count, a.auth AS auth, a.city_id AS city_id, a.outside_location AS outside_location,
a.poster_email AS poster_email, a.apply_online AS apply_online, b.name AS category_name,
DATE_ADD(created_on, INTERVAL 30 DAY) AS closed_on, DATEDIFF(NOW(), created_on) AS days_old
FROM jobs a, categories b
WHERE a.category_id = b.id AND a.id = ' . $job_id;Change to:
$sql = 'SELECT a.type_id AS type_id, a.category_id AS category_id, a.title AS title, a.description AS description,
a.company AS company, a.url AS url, a.apply AS apply,
DATE_FORMAT(a.created_on, \'%d-%m-%Y\') AS created_on, a.created_on AS mysql_date,
a.is_temp AS is_temp, a.is_active AS is_active, a.spotlight AS spotlight,
a.views_count AS views_count, a.auth AS auth, a.city_id AS city_id, a.outside_location AS outside_location,
a.poster_email AS poster_email, a.apply_online AS apply_online, b.name AS category_name,
DATE_ADD(created_on, INTERVAL 30 DAY) AS closed_on, DATEDIFF(NOW(), created_on) AS days_old
FROM jobs a, categories b
WHERE a.category_id = b.id AND a.id = ' . $job_id;Find (this entry is double in class.Job.php, you can remove one of the entries):
$this->mIsActive = $row['is_active'];Add below:
$this->mIsSpotlight = $row['spotlight'];Find 2x:
'is_active' => $this->mIsActive,Add below 2x:
'is_spotlight' => $this->mIsSpotlight,Find:
public function GetJobs($type_id = false, $categ_id = false, $limit = false, $random, $days_behind, $for_feed = false, $city_id = false, $type_id = false)Change to:
public function GetJobs($type_id = false, $categ_id = false, $limit = false, $random, $days_behind, $for_feed = false, $city_id = false, $type_id = false, $spotlight = false)Find:
if ($type_id && is_numeric($type_id))
{
$conditions .= ' AND (type_id = ' . $type_id . ')';
}Change to:
if ($type_id && is_numeric($type_id))
{
$conditions .= ' AND (type_id = ' . $type_id . ')';
}
if ($spotlight && is_numeric($spotlight))
{
$conditions .= ' AND spotlight = ' . $spotlight;
}Find:
// Deactivate an active job post
public function Deactivate()
{
global $db;
$sql = 'UPDATE jobs SET is_active = 0 WHERE id = ' . $this->mId;
$db->query($sql);
}
Add below:
// Activate spotlight-feature for a job post
public function SpotlightActivate()
{
global $db;
$sql = 'UPDATE jobs SET spotlight = 1 WHERE id = ' . $this->mId;
$db->query($sql);
}
// Deactivate spotlight-feature for a job post
public function SpotlightDeactivate()
{
global $db;
$sql = 'UPDATE jobs SET spotlight = 0 WHERE id = ' . $this->mId;
$db->query($sql);
}4. In "/_templates/home.tpl":
Find:
{if $latest_jobs}
<h2>{$translations.homepage.recent_jobs}</h2>
<table id="job-posts" class="job-posts" cellspacing="0">
{foreach item=job from=$latest_jobs}Add above:
{if $spotlight_jobs}
<h2>Spotlight Jobs</h2>
<table id="job-posts4" class="job-posts4" cellspacing="0">
{foreach item=job from=$spotlight_jobs}
<tr>
<td>
{if $job.type_id == $smarty.const.JOBTYPE_FULLTIME}
<img src="{$BASE_URL}img/icon-fulltime.png" alt="fulltime" />
{elseif $job.type_id == $smarty.const.JOBTYPE_PARTTIME}
<img src="{$BASE_URL}img/icon-parttime.png" alt="parttime" />
{elseif $job.type_id == $smarty.const.JOBTYPE_FREELANCE}
<img src="{$BASE_URL}img/icon-freelance.png" alt="freelance" />
{/if}
<a href="{$BASE_URL}job/{$job.id}/{$job.url_title}" title="{$job.title}">{$job.title}</a> <span class="la">{$translations.homepage.at}</span> {$job.company}{if $job.location == 'Anywhere'}, {$job.location}{else} <span class="la">{$translations.homepage.in}</span> {$job.location}{/if}
</td>
<td class="spotlight-image"><img src="{$BASE_URL}img/icon-spotlight.png" alt="" /></td>
</tr>
{/foreach}
</table>
{/if}in "/_css/screen.css":
Add anywhere:
table#job-posts4 {
width: 100%;
border-top: 1px solid #ddd;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
}
table#job-posts4 tr {
background: #fffad4;
}
table#job-posts4 tr.over td {
background: #f5fefe;
}
table#job-posts4 tr.alt td {
background: #f5f5f5;
}
table#job-posts4 td {
padding: 5px;
border-bottom: 1px solid #ddd;
}
table#job-posts4 a:link, table#job-posts4 a:visited {
color: #0099CC;
padding: 2px;
}
table#job-posts4 a:hover {
background-color: #0099CC;
color: #fff;
text-decoration: none;
padding: 2px;
}
table#job-posts4 td.spotlight-image {
text-align: right;
color: #888;
font-size: 11px;
width: 80px;
}5. In "/admin/index.php"
Find:
default:
$flag = 0;
break;Add ABOVE:
case 'activate-spotlight':
if(!isset($_SESSION['AdminId']))
{
redirect_to(BASE_URL);
exit;
}
require_once 'page_activate_spotlight.php';
$flag = 1;
break;
case 'deactivate-spotlight':
if(!isset($_SESSION['AdminId']))
{
redirect_to(BASE_URL);
exit;
}
require_once 'page_deactivate_spotlight.php';
$flag = 1;
break;6. In "/admin/_templates/posts-loop.tpl":
Find:
{if $job.is_active == 0}
<a id="activateLink{$job.id}" href="javascript:void(0);" onclick="Jobber.Activate('{$BASE_URL_ADMIN}activate/', {$job.id}, {if $CURRENT_PAGE == ''}1{else}0{/if});" title="activate"><img src="{$BASE_URL}img/icon_accept.gif" alt="activate" /></a>
{else}
<a id="deactivateLink{$job.id}" href="javascript:void(0);" onclick="Jobber.Deactivate('{$BASE_URL_ADMIN}deactivate/', {$job.id});" title="deactivate"><img src="{$BASE_URL}img/icon_deactivate.gif" alt="deactivate" /></a>
{/if} Add above:
{if $job.is_spotlight == 0}
<a id="activateSpotlight{$job.id}" href="javascript:void(0);" onclick="Jobber.SpotlightActivate('{$BASE_URL_ADMIN}activate-spotlight/', {$job.id}, {if $CURRENT_PAGE == ''}1{else}0{/if});" title="activate-spotlight"><img src="{$BASE_URL}img/icon_spotlight_activate.gif" alt="activate" /></a>
{else}
<a id="deactivateSpotlight{$job.id}" href="javascript:void(0);" onclick="Jobber.SpotlightDeactivate('{$BASE_URL_ADMIN}deactivate-spotlight/', {$job.id});" title="deactivate-spotlight"><img src="{$BASE_URL}img/icon_spotlight_deactivate.gif" alt="deactivate" /></a>
{/if} 7. In "/_js/functions.js"
Find:
Deactivate: function(url, job_id)
{
$.ajax({
type: "POST",
url: url,
data: "job_id=" + job_id,
success: function(msg) {
if (msg != "0")
{
var currentLinkId = 'deactivateLink'+job_id;
Jobber.job_id = job_id;
document.getElementById(currentLinkId).setAttribute('onclick', Jobber.ActivateLink);
document.getElementById(currentLinkId).onclick = Jobber.ActivateLink;
document.getElementById(currentLinkId).innerHTML = '<img src="'+Jobber.jobber_url+'img/icon_accept.gif" alt="activate" />';
document.getElementById(currentLinkId).id = 'activateLink'+job_id;
}
}
});
},Add BELOW:
DeactivateSpotlight: function()
{
var url = Jobber.jobber_admin_url+'deactivate-spotlight/';
Jobber.SpotlightDeactivate(url, Jobber.job_id);
},
ActivateSpotlight: function()
{
var url = Jobber.jobber_admin_url+'activate-spotlight/';
Jobber.SpotlightActivate(url, Jobber.job_id, 0);
},
SpotlightActivate: function(url, job_id, is_first_page)
{
$.ajax({
type: "POST",
url: url,
data: "job_id=" + job_id,
success: function(msg) {
if (msg != "0")
{
var currentRowId = 'item'+job_id;
var currentLinkId = 'activateSpotlight'+job_id;
if(is_first_page == 1)
{
$("#"+currentRowId).css({ display: "none" });
}
else
{
Jobber.job_id = job_id;
document.getElementById(currentLinkId).setAttribute('onclick', Jobber.DeactivateSpotlight);
document.getElementById(currentLinkId).onclick = Jobber.DeactivateSpotlight;
document.getElementById(currentLinkId).innerHTML = '<img src="'+Jobber.jobber_url+'img/icon_spotlight_deactivate.gif" alt="deactivate" />';
document.getElementById(currentLinkId).id = 'deactivateSpotlight'+job_id;
}
}
}
});
},
SpotlightDeactivate: function(url, job_id)
{
$.ajax({
type: "POST",
url: url,
data: "job_id=" + job_id,
success: function(msg) {
if (msg != "0")
{
var currentLinkId = 'deactivateSpotlight'+job_id;
Jobber.job_id = job_id;
document.getElementById(currentLinkId).setAttribute('onclick', Jobber.ActivateSpotlight);
document.getElementById(currentLinkId).onclick = Jobber.ActivateSpotlight;
document.getElementById(currentLinkId).innerHTML = '<img src="'+Jobber.jobber_url+'img/icon_spotlight_activate.gif" alt="activate" />';
document.getElementById(currentLinkId).id = 'activateSpotlight'+job_id;
}
}
});
},8. Extract the contents of the .zip
The following files should be uploaded from the this zip file.
icon_spotlight_activate.gif -> /img
icon_spotlight_deactivate.gif -> /img
icon-spotlight.png -> /img
page_deactivate_spotlight.php -> /admin
page_activate_spotlight.php -> /admin
Feel free to ask if there's any questions about this modification ![]()
Last edited by Chronos (2009-02-24 16:48:25)
Visit my Blog: ChronoScripts (JobberBase scripts, support and freelance)
JobBoards: Telefonisch Werk and Top Bijbaan