jobberBase custom development and support


Code School

Add Tags When Posting a Job

this tutorial is very similar to adding the salary range, except for some few differences. but here’s how you can add tagging when posting jobs.






to begin, on your jobberbase “jobs” table, run this sql script

ALTER TABLE `jobs` ADD `tags` VARCHAR( 255 ) NULL

in /_includes/translations.ini, add anywhere

tags_with = "Jobs tagged with"
no_tags_with = "The are currently no jobs tagged with"

in /_includes/translations.ini, add under [publish]

tags ="Tags"
tags_warning = "Separate each tags by comma or space"

on /index.php, below:

// per city
case 'jobs-in':
	require_once 'page_city.php';
	$flag = 1;

add the following:

// per tags
case 'job-tags':
	require_once 'page_tags.php';
	$flag = 1;

open up /page_job.php add this on top, before “$job_flag = false;”

$tags_array = array();

and on the same page, before the line “$smarty->assign(‘job’, $info);”

// ######### get job's tags, if any #########
if (!empty($info['tags']))
	// filter string from other separator characters aside from space (" ")
	$spchars = array(",",".",";",":");
	$tags_string = str_replace($spchars," ", trim($info['tags']));
	// explode string to an array
	$tags_array = explode(" ", trim($tags_string));
	$smarty->assign('tags', $tags_array);
// ######### get job's tags, if any #########

now create a new file on the root folder called page_tags.php and add the following code:

	if ($extra == 'full-time')
		$type_id = JOBTYPE_FULLTIME;
	else if ($extra == 'part-time')
		$type_id = JOBTYPE_PARTTIME;
	else if ($extra == 'freelance')
		$type_id = false;
	$tag_key = $id;
	if ($tag_key)
		$jobCount = $job->GetJobsCountForTag($tag_key);
		$smarty->assign('jobs_count', $jobCount);
		redirect_to(BASE_URL . 'page-unavailable/');
	$paginatorLink = BASE_URL . "job-tags/$tag_key";
	if (isset($extra))
		$paginatorLink .= "/$extra";
	$paginator = new Paginator($jobCount, JOBS_PER_PAGE, @$_REQUEST['p']);
	$firstLimit = $paginator->getFirstLimit();
	$lastLimit = $paginator->getLastLimit();
	$the_jobs = array();
	$the_jobs = $job->GetJobsByTagKey($id, $firstLimit, JOBS_PER_PAGE, 1);
	$smarty->assign('jobs', $the_jobs);
	$smarty->assign('tag_key', $id);
	$smarty->assign('seo_title', 'Jobs tagged with "' . $id .'"');
	$smarty->assign('seo_desc', '');
	$smarty->assign('seo_keys', '');
	$template = 'tag-jobs-header.tpl';

on /_templates/publish-write.tpl, under

<!-- #textile-suggestions -->

add beneath it:

<!-- Job Tags -->
	<td class="publish-label" valign="top">{$translations.publish.tags}:</td>
	<td><input type="text" name="tags" id="tags" tabindex="7" size="50" value="{if $job.tags}{$job.tags}{else}{$}{/if}" />
<br />
<div class="suggestion">
<!-- /Job Tags -->

on /_includes/class.Job.php, add on the vars list

var $mTags = false;

under the first SELECT statement after this line:

a.is_temp AS is_temp, a.is_active AS is_active, a.spotlight AS spotlight,

add this line:

a.tags as tags,

on the $this-> list after the SELECT statement, add after “$this->mIsSpotlight = $row[‘spotlight’];”

$this->mTags = $row['tags'];

add on public function GetInfo() and public function GetBasicInfo() and public function GetBasicInfoAdmin(), before the line ‘is_spotlight’ => $this->mIsSpotlight);

'tags' => $this->mTags,

on public function Create($params), on the INSERT INTO jobs block, add after INSERT INTO jobs (type_id, category_id, title, description, company, city_id, url, apply,:


and on the same block, add before the line NOW(), 1, 0, 0, “‘ . $this->GenerateAuthCode() . ‘”,

"' . $params['tags'] . '",

to allow editing, on public function Edit($params), on the UPDATE jobs SET block, add after apply = “‘ . $params[‘apply’] . ‘”,:

and add at the bottom of the page before the last }

//############## tagging ######################
// Get jobs count by tag
public function GetJobsCountForTag($tag_key)
	global $db;
	$sql = 'SELECT COUNT(id) AS total FROM jobs WHERE is_temp = 0 AND is_active = 1 AND tags LIKE "%' . $tag_key . '%"';
	$result = $db->query($sql);
	$row = $result->fetch_assoc();
	return $row['total'];
// Get all jobs by tag
public function GetJobsByTagKey($tag_key = false, $firstLimit = false, $lastLimit=false, $random)
	global $db;
	$jobs = array();
	if ($random == 1)
		$order = ' ORDER BY RAND() ';
		$order = ' ORDER BY created_on DESC ';
	if ($firstLimit >= 0 && $lastLimit >= 0)
		$sql_limit = 'LIMIT ' . $firstLimit .', ' . $lastLimit;
			$sql_limit = '';        
	$sql = 'SELECT id FROM jobs 
			WHERE is_temp = 0 
			AND is_active = 1 
			AND tags LIKE "%' . $tag_key . '%"
			' . $order . ' ' . $sql_limit;
	$result = $db->query($sql);
	while ($row = $result->fetch_assoc())
		$current_job = new Job($row['id']);
		$jobs[] = $current_job->GetInfo();
	return $jobs;
//############## tagging ######################

now on page_write.php on the root folder, find the blocks (there are 2) which starts with $data = array( and add the following before the line ‘apply_online’ => $apply_online);

'tags' => $tags,

then on /_includes/job-details.tpl, before:

<div id="job-description">

add the following:

<!-- Tagging -->
<span class="fading">{$translations.publish.tags}:</span>
{if count($tags) > 0}
{foreach item=tag from=$tags}
	{if $tag != NULL}
	<a href="{$BASE_URL}job-tags/{$tag}/">{$tag}</a>
<!-- Tagging -->

on /_templates, create a file called tag-jobs-header.tpl and add the following:

{include file="header.tpl"}
<div id="content">
<div id="job-listings">
	{if $jobs}
	<div id="sort-by-type">
	<a href="{$BASE_URL}jobs-tag/{$tag_key}/full-time/" title="{$tag_key} full time"><img src="{$BASE_URL}img/icon-fulltime.png" alt="{$tag_key} full time" /></a>
	<a href="{$BASE_URL}jobs-tag/{$tag_key}/part-time/" title="{$tag_key} part time"><img src="{$BASE_URL}img/icon-parttime.png" alt="{$tag_key} part time" /></a>
	<a href="{$BASE_URL}jobs-tag/{$tag_key}/freelance/" title="{$tag_key} freelance"><img src="{$BASE_URL}img/icon-freelance.png" alt="{$tag_key} freelance" /></a>
	</div><!-- #sort-by-type -->
	{$translations.jobtags.tags_with} "{$tag_key}" ({$jobs_count})
	{include file="posts-loop-tags.tpl"}
	</div><!-- #job-listings -->
</div><!-- #content -->
{include file="footer.tpl"}

create another file on /_templates/, create another file named posts-loop-tags.tpl

{if $is_home == 1}
<div><a href="{$BASE_URL}">&laquo; home</a></div>
{if $no_categ != 1}
<table id="job-posts" class="job-posts" cellspacing="0">
{if !$jobs}
<div id="no-ads">
	{$translations.jobtags.no_tags_with} "<strong>{$tag_key}</strong>".<br />
	<a href="{$BASE_URL}post/" title="{$translations.footer.new_job_title}">{$translations.footer.new_job}</a>
</div><!-- #no-ads -->
{foreach item=job from=$jobs}
	{if $job.type_id == $smarty.const.JOBTYPE_FULLTIME}
	<img src="{$BASE_URL}img/icon-fulltime.png" alt="full-time" />
	{elseif $job.type_id == $smarty.const.JOBTYPE_PARTTIME}
	<img src="{$BASE_URL}img/icon-parttime.png" alt="part-time" />
	{elseif $job.type_id == $smarty.const.JOBTYPE_FREELANCE}
	<img src="{$BASE_URL}img/icon-freelance.png" alt="freelance" />
	<a href="{$BASE_URL}job/{$}/{$job.url_title}/" title="{$job.title}">{$job.title}</a> <span class="la">{$}</span> {$}{if $job.location == 'Anywhere'}, {$job.location}{else} <span class="la">{$}</span> {$job.location}{/if}
	<td class="time-posted"><img src="{$BASE_URL}img/clock.gif" alt="" /> {$job.created_on}</td>
<script type="text/javascript">
	$(".job-posts tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
	$(".job-posts tr:odd").addClass("alt");


Code School

  1. Are these searchable? Thanks for a GREAT! tutorial

  2. hi, you would have to add the tags field on the search function on class.Job.php, should be easy though if you’ve worked with jobberbase already.

  3. hi, this mod does not include the tags (yet) as searchable, but this can easily be done. you just need to update the search function on the class.Job.php to include the field ‘tags’ on the jobs table.

  4. After inputting info, I have just a white screen and I’ve followed the steps all the way.

  5. hi, please turn your error reporting on and let me know what error you are getting. none has reported that this isn’t working so far.

  6. Would be nice if you could work out how to add a tagcloud to the sidebar (like a companycloud).

  7. hi, let me think about that 😉 i haven’t had a lot of time lately…but when i do, i’ll write a tutorial for it. by the way, keep me posted on the jobberBase on steroids version that you are coming up with!

  8. Thanks. Great post.
    I have a problem though.

    When I publish a job with say the folowing tags:, programmer, c#
    the resulting tags look like this:
    asp net programmer c#

    The period is being removed from the tag.
    Does the tag have to be urlencoded?
    How can I fix this?

  9. hi, you just need to exclude period (.) from the “explode” statement in the code (sorry i’m not in front of the code right now so just trying to recall from memory.)

    this explode line filters the string from possible separators like comma or space, etc. so just remove the part “.”, from the line where you find this.

  10. hi,
    I have a problem. When I click a tag
    and the page is displayed “Jobs tagged with “tag” (1)”, then when I click one of the “Only display – fulltime, parttime, freelance” links I get the following error:
    We’re sorry, but the page you were looking for could not be found.

  11. Hello?

    This is a bug…

  12. hi there, thanks for reporting this bug. right now i don’t have much time to work on a fix, but if you do find a solution, feel free to post it here! 😉

  13. Hey Redjumpsuit,

    Thanks again for this great add on. But of course it doesn’t work properly. If you go to my test site you see the block for filling out the code but not the text description. What am I doing wrong?

    Truly love your stuff!!! :)

  14. Well I’ve got it working on my test site :) and thanks again for this add on but I’ve got one question/request. You’ve stated before that’s quite easy to make Tags searchable. Somewhere in page_job.php but can you point out to me how to create this function in the search block of code?

    Thanks a lot!!

  15. @tightredjumpsuit 😉

    On page_tag.php change “$smarty->assign(‘seo_title’, ‘Jobs tagged with “‘ . $id .'”‘);” into “$translations[‘tags’][‘page_title’]” and include it in the language file.

    Still having some trouble with it, but I’m trying to solve it. If I have the solution I’ll post it.

  16. He, I’m having trouble adding the tag field and the salary range hack. The salarymax value is being inserted als tag and the salarymax value stays empty (making it to not show on the template). Any solution for that?

  17. hi evert, i will try to look into that when i get back (i am away on a trip and will be back saturday) and help you out. but until then, cheers!

  18. Hi very good,

    I have a problem with strange characters such as accents and

  19. Hmm, I can’t see this tutorial. Any chance of getting it working again? I’d love to use it.

  20. Is it possible to have the tutorial back as I really need it. Also, does it work on Jobberbase 1.9.1?

  21. this works for jobberBase 1.7, 1.8 but never tried this on 1.9.1. you will need to convert the code to the new version as some fields may have already changed

  22. many thanks!!!

  23. Hey,
    I was doing as said (Am using jobberbase 1.9.1) you said the translation file in _includes folder, but there is no such file.. I checked in the themes folder where i got it.
    I added all the said script overthere.

    Then you asked the script on index.php.. however i just could not find the words ( // per city .. and so)….

    so now i am stuck right in between.. as you said.. 1.9.1 is updated and things must have changed.. when would you be giving up a updated article?

    Please need your help here.


  24. hi, no time to migrate this code to the new version unfortunately. if you get this to work with the new version, feel free to share it here!

  25. I can confirm it can be made compatible with V2.0 along with few changes to Code.

    Also changed few Static references to Dynamic like Type of Jobs ( it was static to Full Time/Part Time/Freelance)

    Also added the Admin Module Edit compatibility

    Great Code Thanks for sharing the same.

Leave a Response