grubix

Topic: Sidebar - only show categories with job listings

To get the same behaviour as you would expect for the cities choice, i.e. to only show the categories that have 1 or more job in them, seek out your page_home.php file.

Find the following code (line 9 onwards for Jobberbase 1.9.1):

Code:
if (SIDEBAR_SHOW_WHAT == 'categories')
    {
        $smarty->assign('jobs_count_all_categs', $job->GetJobsCountForAllCategs());
    }
    else...

(the 'else' goes on to give the functionality for showing the cities rather than categories, and you can see the difference in the amount of code)

Change the following line (i.e. what is inside the curly brackets):

Code:
        $smarty->assign('jobs_count_all_categs', $job->GetJobsCountForAllCategs());

to the following new code:

Code:
        $myCategCount = $job->GetJobsCountForAllCategs();
                
        foreach ($myCategCount as $index => $jobsPerCateg)
        {
            if ($jobsPerCateg['categ_count'] < 1)
                unset($myCategCount[$index]);
        }
        
        $smarty->assign('jobs_count_all_categs', $myCategCount);

Hey presto! Now only the categories with more than one job show on the list.