Category Jobs Filter
the jobs listed in the category can get long and sometimes irrelevant anymore to those looking for jobs, so to keep the list relevant, there is a way job seekers can filter the jobs in the category they are looking at. here is a sample screenshot:
and here is an instruction on how it can be done:
Open up /_includes/translations.ini and add this:
[header] filter_jobs = "Filter Jobs" [filter] day = "24 Hours" week = "1 Week" month = "1 Month"
Open up /_templates/sidebar.tpl
Before the line:
{if $CURRENT_PAGE != ''}
Add this block:
{if $current_category != 'home' && $current_category != ''} <h4>{$translations.header.filter_jobs}</h4> <ul> <li> {if $filter != 'h'} <a href="{$BASE_URL}advanced/{$current_category}/h/">{$translations.filter.day}</a> {else} <strong><a href="#">{$translations.filter.day}</a></strong> {/if} </li> <li> {if $filter != 'w'} <a href="{$BASE_URL}advanced/{$current_category}/w/">{$translations.filter.week}</a> {else} <strong><a href="#">{$translations.filter.week}</a></strong> {/if} </li> <li> {if $filter != 'm'} <a href="{$BASE_URL}advanced/{$current_category}/m/">{$translations.filter.month}</a> {else} <strong><a href="#">{$translations.filter.month}</a></strong> {/if} </li> </ul> <br /> {/if}
Create a file on the root folder named ‘page_advancedsearch.php’ and paste this code:
<?php $list = new AdvancedSearch(); $the_jobs = array(); $the_jobs = $list->filterjobs($extra,50,$id); $smarty->assign('jobs', $the_jobs); $smarty->assign('current_category', $id); $smarty->assign('filter', $extra); $smarty->assign('seo_title', get_seo_title($id)); $smarty->assign('seo_desc', get_seo_desc($id)); $smarty->assign('seo_keys', get_seo_keys($id)); $template = 'category.tpl'; ?>
Create a file on your /_includes folder called ‘class.AdvancedSearch.php’ and paste this code:
<?php /** * jobber job board platform * * @author RedJumpsuit <myredjumpsuit@gmail.com> * @web www.redjump.co.cc * * Advanced Search is used for more extensive searching */ class AdvancedSearch { function __construct() { } public function filterjobs($filter,$per_page=50,$catname) { global $db; $jobs = array(); $condition = ''; // 1 day if ($filter == 'h') { $condition = ' AND a.created_on >= DATE_SUB(NOW(),INTERVAL 1 DAY) '; } // 1 week elseif ($filter == 'w') { $condition = ' AND a.created_on >= DATE_SUB(NOW(), INTERVAL 1 WEEK ) '; } // 1 month else { $condition = ' AND a.created_on >= DATE_SUB(NOW(),INTERVAL 1 MONTH ) '; } $sql = 'SELECT a.*, b.name AS city_name, c.name AS category_name, REPLACE(LOWER(a.title)," ","-") AS url_title FROM jobs a, cities b, categories c WHERE a.city_id = b.id AND a.category_id = c.id AND c.var_name = "'. $catname .'"'. $condition . ' LIMIT 0, '. $per_page; $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $jobs[] = $row; } if ($jobs) { return $jobs; } } } ?>
Second to the last, open your index.php and under this block:
// per category case 'jobs': require_once 'page_category.php'; $flag = 1; break;
Add this block
// per filter case 'advanced': require_once 'page_advancedsearch.php'; $flag = 1; break;
Finally, open up your config.php file and add this at the end of the require_once class list:
// advanced search require_once '_includes/class.AdvancedSearch.php';









Wonderful!
I am missing city names on filtered results.
You are a life saving rockstar!!!!
hi, i noticed this
just need to rename the city name to the name displayed by the template. will update this tutorial later! thanks for the bug report!
Thanx, replaced city_name with location in class.AdvancedSearch.php and it works!
I tried to apply the mod, but it returns a blank page. Please help.
the filter links have the format of “http://www.sitename.com/advanced/catgegory/h/”
thanks.
hi, please double-check your code with the instructions
a lot of people have implemented this mod and you are the first to report an error for this!
Not work change city_name for city_location … anyone have a response?
This php code is great. very easy to install.
pls update code for 1.8
thx
How to get date formatted as 0ct 17th?
you can see the valid formats here:
http://www.smarty.net/manual/en/language.modifier.date.format.php
Hi,
This looks really great. Is this for v1.7 at the moment?
Would it be possible to get for v1.8 please.
Thanks again
can i do change change the main tabs of the website instead of job with cities and can i use that feature once i do that thanks in advance
more explainations i want to add a dropdown tab containing find a job contains these choises find a job,cities
My jobberbase is basically for RTL – right to left languages, it is nota big deal , just mirroring every thing.
However adding what you explained give me the following error:
Fatal error: Call to undefined function get_seo_title() in C:\xampp\htdocs\jobberbase\page_advancedsearch.php on line 12
I believe that in your last step:
Finally, open up your config.php file and add this at the end of the require_once class list:
// advanced search
require_once ‘_includes/class.AdvancedSearch.php’;
I could not know where this config.php located . Made a search foun 2 files in this name.
Also where to paste exactly?? could not understand
I guess there is some problems with joomla 1.8
When adding this filter to the sidebar , so the LAsteViewedJobs title , and Home title disappears.
Something wrong here?? I tried to fix , but did not succeed.
Maybe you can answer and help please??
Hi
Fatal error: Call to undefined function get_seo_title() in C:\xampp\htdocs\jobberbase\page_advancedsearch.php
might seem trivial, but I cannot work out why its doing this (only just getting to grips with Jobberbase 1.9). No solution found so far.
Where is this function defined? (presume simple problem of file path?) It should be a function of Smarty class no? Nothing can be found there.
thanks
it’s on /_includes/functions.php
there is no function get_seo_title() in _includes/functions.php !!!? Jobberbase 1.9.1
because this is 1.9.x, the tutorial is for jobberBase 1.8