RedJumpsuit

jobberBase custom development and support

 

Code School

Show recent job applications

for: jobberBase 1.9.1

this tutorial will show you how to display most recent applied to jobs (as opposed to most applied to jobs.) it will display jobs with the most recent applications (but not necessarily the most popular job)

recent-applied

open page_home.php and add this on the list of the define block:

define('NUMBER_OF_RECENT_APPLIED_TO_JOBS_TO_GET', $settings['most_applied_jobs']);

on the same page, after this line:

$smarty->assign('most_applied_to_jobs', $job->GetMostAppliedToJobs(NUMBER_OF_MOST_APPLIED_TO_JOBS_TO_GET));

add this:

$smarty->assign('recent_applied_to_jobs', $job->GetRecentAppliedJobs(NUMBER_OF_RECENT_APPLIED_TO_JOBS_TO_GET));

next, open /_includes/class.Job.php and look for this block:

public function GetMostAppliedToJobs($limit = false)
	{
}

add this after:

public function GetRecentAppliedJobs($limit = false)
	{
		global $db;
 
		$jobs = array();
 
		$sql_limit = 'LIMIT ' . $limit;
 
		$sql = 'SELECT job_id AS job_id, DATE_FORMAT(created_on, "' . DATE_FORMAT . '") AS applied_on FROM  '.DB_PREFIX.'job_applications 
				ORDER BY created_on DESC ' . $sql_limit;
		$result = $db->query($sql);
		while ($row = $result->fetch_assoc())
		{
			$current_job = new Job($row['job_id']);
			$job = $current_job->GetInfo();
			$job['applied_on'] = $row['applied_on'];
			$jobs[] = $job;
		}
		return $jobs;
	}

third, open /_templates/default/home.tpl and after this block:

{if $most_applied_to_jobs}
	<br />
	<h2>{$translations.homepage.popular_jobs}</h2>
 
	{foreach item=job from=$most_applied_to_jobs}
		<div class="{cycle values='row,row-alt'}">
			<span class="row-info">
				<img src="{$BASE_URL}_templates/{$THEME}/img/icon-{$job.type_var_name}.png" alt="{$job.type_name}" />
				<a href="{$BASE_URL}{$URL_JOB}/{$job.id}/{$job.url_title}/" title="{$job.title}">{$job.title}</a> <span class="la">{$translations.homepage.at}</span> {$job.company}{if $job.is_location_anywhere}, {$translations.jobs.location_anywhere}{else} <span class="la">{$translations.homepage.in}</span> {$job.location}{/if}
			</span>
			<span class="time-posted"><strong>{$job.apps}</strong> {$translations.homepage.applicants}</span>			
		</div>
	{/foreach}
{/if}

add this block:

{if $recent_applied_to_jobs}
	<br />
	<h2>{$translations.homepage.applied_jobs}</h2>
	{foreach item=job from=$recent_applied_to_jobs}
		<div class="{cycle values='row,row-alt'}">
			<span class="row-info">
				<img src="{$BASE_URL}_templates/{$THEME}/img/icon-{$job.type_var_name}.png" alt="{$job.type_name}" />
				<a href="{$BASE_URL}{$URL_JOB}/{$job.id}/{$job.url_title}/" title="{$job.title}">{$job.title}</a> <span class="la">{$translations.homepage.at}</span> {$job.company}{if $job.is_location_anywhere}, {$translations.jobs.location_anywhere}{else} <span class="la">{$translations.homepage.in}</span> {$job.location}{/if}
			</span>
			<span class="time-posted"><img src="{$BASE_URL}_templates/{$THEME}/img/clock.gif" alt="" /> {$job.applied_on}</span>			
		</div>
	{/foreach}
{/if}

also replace this:

{if !$latest_jobs && !$most_applied_to_jobs}

with this:

{if !$latest_jobs && !$most_applied_to_jobs && !$recent_applied_to_jobs}

lastly, open /_templates/default/_translations/translations_en.ini and add this under [homepage]:

applied_jobs = "Recent applied to IT jobs"

that should be it. enjoy!

Tagged as:

3 Comments

Code School

  1. Hello, Thank you for the hack. It works but I have the following concerns.

    1. A job applied to shows more than once on the page. Only one instance of that job should show.

    2. How can I disable “most applied to job” without affecting “recent applied to jobs”

    Thank you.

  2. @NigeriaJobVacancy (it’s a little late I know :) )
    To get the job to only show up once: change your sql function in “public function GetRecentAppliedJobs()” to use a group by

    My Code is below:
    change your public function GetRecentAppliedJobs (step 2)
    To:

    public function GetRecentAppliedJobs($limit = false)
    {
    global $db;

    $jobs = array();

    $sql_limit = ‘LIMIT ‘ . $limit;

    $sql = ‘SELECT job_id AS job_id, max(DATE_FORMAT(created_on, “‘ . DATE_FORMAT . ‘”)) AS applied_on FROM ‘.DB_PREFIX.’job_applications
    GROUP by job_id
    ORDER BY created_on DESC ‘ . $sql_limit;
    $result = $db->query($sql);
    while ($row = $result->fetch_assoc())
    {
    $current_job = new Job($row[‘job_id’]);
    $job = $current_job->GetInfo();
    $job[‘applied_on’] = $row[‘applied_on’];
    $jobs[] = $job;
    }
    return $jobs;
    }

    Thanks RedJumpSuit for the awesome site!

  3. The function needs to be adjusted to display active jobs only.

Leave a Response