Working with Additional Fields

Additional fields is one of the most widely used features in WPJobBoard, however users sometimes have problems with displaying field value on jobs/resumes list, this guide will help you do that.

Most of the time users want to display one of additional fields in the jobs/resumes list or job/resume details page (despite the fields are already listed there). First thing you will need to do is check additional field ID. Go to administration panel > Additional Fields page (/wp-admin/admin.php?page=wpjb/addField) and in the table find ID of the field you want to display.

Next, open file wpjobboard/templates/job-board/index.php and somewhere in the loop add following code

<?php
echo $job->getFieldValue($field_id)
// obviously replace $field_id with your selected field id
?>

it will display additional field value or nothing if the value was not set when posting a job. You can use the getFieldValue() method in files where you have access to $job variable (job-board/single.php, job-board/job.php, job-board/index.php).

Simimlarly you can use getFieldValue() method for resumes everywhere you have access to $resume variable (resumes/resumes.php, resumes/resume.php).

Posted in Developer Docs | Leave a comment

Changing Page templates

If you are already familiar with how WPJobBoard templates work, you know that whole job board is using the same Page template. This tutorial will show you how to use different templates for different parts of job board.

Job board Router

In order to figure out on which part of job board you currently are, you will need to use Router object. You can get it with

<?php
$app = Wpjb_Project::getInstance()->getApplication("frontend");
// replace "frontend" with "resumes" to get resumes router
$router = $app->getRouter();
// now $router is an instance of Daq_Router
?>

Now that you have access to router you can test if you are (for example) on Add a job page. You can do it using isRoutedTo(“module.action”) method, here is how it should look like:

<?php
$routed = $router->isRoutedTo("addJob.add");
// $routed is bool now

In order to find other “module.action” combinations open file wpjobboard/application/config/frontend-routes.ini (or resumes-routes.ini for Resumes). Each entry looks similar to

[step_add]
pattern = "add/*"
module = "addJob"
action = "add"

This is where i get the module.action combination from.

Changing the Page template

Now that you know how to check on which job board template you are it’s time to put this knowledge into use. You will want to change the default template, so you will need to use WordPress template_include filter.

<?php
function my_template_include($tpl) {
    // check if current page is job board page
    if(!is_wpjb()) {
        return $tpl;
    }
    $router = Wpjb_Project::getInstance()->getApplication("frontend");
    $router = $router->getRouter();
    if($router->isRoutedTo("addJob.add")) {
        // return full path to template you want to use
        return dirname($tpl)."/page.php";
    }
    
    // if no route was matched return default template
    return $tpl;
}
add_filter("template_include", "my_template_include");

The code above you can put in your theme functions.php file.

Posted in Cookbook | Leave a comment

XML import

If you need to do a bulk job import, you can do that from WPJobBoard Import panel. Select XML import, select file from your computer and click Import. Your XML file should follow scheme below, otherwise import won’t work.

<?xml version="1.0" encoding="UTF-8" ?>
<wpjb>
  <job>
    <id>1</id>
    <!--
         Optional, Integer uniquely identifying a job,
         if job with given id already exists it will
         be overwritten
    -->
    
    <company_name>Test</company_name>
    <!-- Required -->
    <company_website>http://example.com</company_website>
    <!-- Valid URL starting with http -->
    <company_email>example@example.com</company_email>
    <!-- Required, Valid email address -->
    <company_logo_ext></company_logo_ext>
    <!-- file extension one of jpg, jpeg, png, gif -->
    <company_logo></company_logo>
    <!-- base 64 encoded content of the image file -->
    
    <job_title>Title</job_title>
    <!-- Requrired -->
    <job_description>Some job description</job_description>
    <!-- Requrired -->
    
    
    <category>
        <title>PHP</title>
        <!-- Required, category title -->
        <slug>php</slug>
        <!-- Required, Valid slug,
             If category with given slug won't be found
             new category will be created
        -->
    </category>
    
    <job_type>
        <title>Full Time</title>
        <!-- Required, job type title -->
        <slug>full-time</slug>
        <!-- Required, Valid slug,
             If job type with given slug won't be found
             new category will be created
        -->
        <color></color>
        <!-- Hex color value (without "#") -->
    </job_type>
    
    <job_country>US</job_country>
    <!-- Requred, valid ISO 3166-1 alpha-2 country code -->
    <job_state>New York</job_state>
    <!-- String -->
    <job_zip_code></job_zip_code>
    <!-- String -->
    <job_location>New York</job_location>
    <!-- Location or city name -->
    
    <job_created_at>2011-08-02</job_created_at>
    <!-- Required, job creation date -->
    <job_modified_at>2011-08-02</job_modified_at>
    <!-- Last time job was modified -->
    <job_visible>30</job_visible>
    <!-- Required, number of days job will be visible -->
    
    <is_approved>1</is_approved>
    <!-- Required, boolean 0 or 1 -->
    <is_filled>0</is_filled>
    <!-- Required, is job filled, boolean 0 or 1 -->
    <is_featured>0</is_featured>
    <!-- Required, is job marked as featured, boolean 0 or 1 -->
    
    <payment_sum>10.00</payment_sum>
    <!-- Required, float, total job cost -->
    <payment_paid>10.00</payment_paid>
    <!-- Required, float, how much employer already paid -->
    <payment_currency>USD</payment_currency>
    <!-- Required, string, 3 letter currency code -->
    <payment_discount>0.00</payment_discount>
    
  </job>
</wpjb>

 

Posted in User Guide | 2 Comments

Migrating to version 3.4

WPJobBoard 3.4 has multiple improvements and changes over branch 3.3, unfortunately to make some improvements breaking backwards compatibility was required. This documents will guide in migrating to the latest version.

First of all if you did NOT made any changes in the WPJobBoard templates or core files feel free to ignore this document and just overwrite old files with new ones to upgrade.

If you made changes somewhere outside wpjobboard/templates directory, you can still upgrade but remember that all your changes will be overwritten and if you decide to keep some of the old files (in which you made changes) there is no guarantee that the WPJobBoard will function correctly.

This document is intended mainly for people who followed Knowledge Base guidelines to modifying WPJobBoard templates.

Make a local copy

After you will upgrade to the latest version, WPJobBoard will start to ignore your custom theme in wpjobboard/templates/ directory and will use the default templates instead. It’s because in version 3.4 how WPJB templates work was one of the biggest improvements. To read more about templates in version 3.4 please see Introduction to templates.

This is way you need to create a local copy of your website, and install WPJobBoard 3.4.0 there, probably your layout will somewhat change, however it shouldn’t break your website design, just some minor changes in the layout.

Now according to documentation in Introduction to templates apply the changes you previously made to the new templates files (ie. files in wp-content/themes/{your-theme}/job-board/).

Unfortunately, because modification possibilities are endless it’s beyond the scope of this article to describe how to migrate each change to new version.

Note, some of wpjb_* function were removed or deprecated and it’s no longer recommended to use them in your templates or WordPress themes, instead in each template file there is a documentation specifying available variables in given template.

Final word

Remember that version 3.3.6 is still supported, and if you are unable or don’t want to migrate your job board to branch 3.4 you can stick to 3.3 which will have maintenance (bug fix) releases.

Posted in Developer Docs | Leave a comment

E-mail notifications

WPJobBoard can notify job poster that his add is expiring soon (exactly within 5 days) and ask him to renew the listing if he wants to have it visible on the job board.

In order to enable notifications you need to set CRON jobs. Depending on your hosting company the procedure to setup CRON will differ, so if you have problem with it ask your hosting suppot.

The CRON job is a task that is run periodically on the server. You will want to execute WPJobBoard task once daily. The command to execute is:

wget -q --delete-after http://example.com/jobs/plain/cron

Now you have e-mail notifications set. When one of jobs will expire within 5 days, e-mail will be sent to the e-mail address entered in “Company email” field when posting a job. You can configure e-mail template in WPJobBoard / Email Templates panel.

Posted in Developer Docs | 7 Comments

Application Flow

WPJobBoard has over 300 files, but when modifying WPJB you will be interested usually in one of less then 30 files so it’s important to understand how the plugin works in order to increase development speed.

In WPJobBoard there is a concept of modules, if you are viewing job board then you are viewing module Frontend. You will find this module actions in wpjobboard/wpplication/libraries/Module/Frontend.

You will find there three files (controllers each controller has actions it can execute):

  • Index.php – displays XHTML pages (all job lists, job details, apply for job)
  • AddJob.php – handles job posting
  • Plain.php – displays RSS feeds and integrations XML

With each request only one action is executed (action is a method with postfix Action), for example if you open job board front page then Wpjb_Module_Frontend_Index::indexAction() will be run.

After the action is executed, the appropriate view will be rendered. If the indexAction() did not returned any value then “index.php” file will be used as a template.

Templates are taken from the wpjobboard/templates/{your-theme} directory – you can set {your-theme} in WPJobBoard configuration, by default it’s “twentyten”.

Posted in Developer Docs | Leave a comment

WPJobBoard Router

WPJobBoard router is very powerful “thing”. Basically it allows to modify all permalinks from single ini file. However (like uncle Ben said) with great power comes great responsibility, so before you will start playing with the router read this article carefully.

How Router works?

When WPJobBoard will confirm (in the “wp” filter) that currently displayed page will be a job board or resumes module then the router is executed to detect which job board page (index, add job form, apply form etc.) will be displayed.

The detection is based on URL path. For example by default empty path is a main job board page, “/add” path is a “Add a job” form, “view/(job-name)” is job details page. Each job has unique (job-name) so usually detection is based on regular expressions.

Route files

There are two routes files (actually 3 but the third one is for admin routes which you will probably do not want to modify):

  • wpjobboard/config/frontend-routes.ini – job board routes
  • wpjobboard/config/resumes-routes.ini – resumes routes

You can check them out to see how routes are configured, however if you want to modify or add routes then create file:

  • wpjobboard/environment/frontend-routes.ini – for job board
  • wpjobboard/environment/resumes-routes.ini – for resumes

There are two reasons for this. First when you run automatic update the files in “config” directory will be overwritten and you would loose all your changes, second in case you make an error you can simply delete created route file instead of debugging it.

How routes are defined?

You can say that there are two types of routes, the one that are based only on URL path, and routes that need both URL path and matching row in the database table.

The example of the first category are routes to the add job and index page


[step_add]
pattern = "add/*"
module = "addJob"
action = "add"

[index_page]
pattern = "page/(page)"
module = "index"
action = "index"
param.page = "int"

The most important in both examples is the pattern. You can put there a static string like “post-a-job”, then if Router detects that the URL path is equal to “post-a-job” then job board will display post a job page.

However most of the time you need some variable in the URL, like page number on the list of jobs and in fact the Router allows it. In the pattern variable is a string in parentheses. You also need to define variable type (param.page = “int”) allowed types are “slug”, “string”, “int”.

To sum it up, each request to “page/1″, “page/123″ or “page/643546″ will route to index_page.

The second type of routes are routes that need to match row in the database, for example job details page.


[job]
pattern = "view/(job_slug)"
module = "index"
action = "single"
model = "Wpjb_Model_Job"
param.job_slug = "slug"

The pattern is pretty similar to index_page, however note that there is “model = “Wpjb_Model_Job”" line. It tells the Router that route for example “view/extra-job” will be valid only if in wpjb_job table there is a row with job_slug equal to “extra-job”.

Managing Routes

At the beginning i said that you should create your route files in wpjobboard/environment directory. If you do this then both route files will be loaded and data from wpjobboard/environment will overwrite data from wpjobboard/config. What does this mean? You do not need to copy whole file, you can add or change only the lines you need.

For example if you would like to change pattern of job details routes you can do this by adding to the wpjobboard/environment/frontend-routes.ini following lines:


[job]
pattern = "view/(job_slug).html"
Posted in Developer Docs | Leave a comment

Selecting data from WPJobBoard tables

WPJobBoard is using Daq_Db_Query class to select data from wpjb tables. While using this method will require you to learn Daq_Db_Query interface there few advantages of this method over WP_Query.

First of if you are familiar with Zend_Db_Select you will fill like home (although there are few differences), second you get access directly to WPJobBoard Models not arrays of data.

In case you will want to go directly to the source, then you will find Daq_Db_Query class in wpjobboard/framework/Db/Query.php file

Using Daq_Db

The simplest example, let’s take all jobs from the wpjb_job table.


$query = new Daq_Db_Query();
$query->select("*")->from("Wpjb_Model_Job t1");
echo $query;
// echo: SELECT * FROM wpjb_job AS t1
$jobs = $query->execute(); 

foreach($jobs as $job) {
    /* @var $job Wpjb_Model_Job */
    echo $job->job_title."
"; }

Using where(), limit() and order()

Note few things, you do not pass table name to Daq_Db::from() method, but model name. If you echo the query you will see instead of * there is a list of all fields with aliases, in order to keep examples simple i will just use “*”.

In case you would like to select only 15 jobs which id is between 100 and 200 or id is exactly 1000, ordered by creation date then by id the query would be:


$query = new Daq_Db_Query();
$query->select("*");
$query->from("Wpjb_Model_Job t1");
$query->limit(15);
$query->order("t1.created_at DESC, t1.id ASC");
$query->where("(t1.id > ?", 100);
$query->where("t1.id < ?)", 200);
$query->orWhere("t1.id = ?", 1000);
echo $query;
// echo:
//     SELECT * FROM wpjb_job AS t1 WHERE
//     (t1.id > 100 AND t1.id < 200) OR t1.id = 1000
//    ORDER BY t1.created_at DESC, t1.id ASC LIMIT 15

Important thing to note, while every time you use where() (or orWhere()) method new condition is appended however for limit() and order() conditions are overwritten.

Joining tables

Often you want to select from the database information about jobs along with information about job category and type, with Daq_Db it's simple and you do not even need to remember on which fields join is made.


$query = new Daq_Db_Query();
$query->select("*")->from("Wpjb_Model_Job t1");
$query->join("t1.category t2");
$query->join("t1.type t3");
echo $query;
// echo
//    SELECT * FROM wpjb_job AS t1
//    INNER JOIN wpjb_category AS t2 ON t1.job_category = t2.id
//    INNER JOIN wpjb_type AS t3 ON t1.job_type = t3.id

foreach($query->execute() as $job) {
    echo $job->getid()." - ";
    echo $job->getCategory()->getId()." - ";
    echo $job->getType()->getId()."
"; }

How do i know that i need to do ->join("t1.category t2") ? simple, it's taken from Model references names, so i actually need to know how i named references in my Wpjb_Model_Job rather then all fields names.

When you do need models

You probably noticed that the query is executed when execute() method is used. I like to use this method because it returns Models not just plain array of arrays. That being said you do not always need models, sometimes you just want to count how many rows are there in the wpjb_job table, how to do this using Daq_Db?


$query = new Daq_Db_Query();
$query->select("COUNT(*) AS cnt")->from("Wpjb_Model_Job t1");
$result = $query->fetchColumn();

Now $result contains number of rows in the wpjb_job table.

Posted in Developer Docs | Leave a comment

Job Aggregators (Indeed, SimplyHired, Juju, Google Base)

In order to integrate with job aggregators (usually to gain more targeted traffic) you need to create XML file with information about job you have active on your job board – fortunately WPJobBoard has it handled for you. All you need to do is submit this file URL to the aggregator.

Note that in order to avoid SPAM and duplicate content jobs that were automatically imported from CareerBuilder won’t be published in the feed.

Indeed

It’s entirely free to integrate with Indeed.

Simply create advertiser account at https://ads.indeed.com/includejobs then login and submit your feeds.

XML File URL: http://example.com/jobs/api/indeed
(Without permalinks: http://example.com/index.php?page_id=zxc&job_board=/jobs/api/indeed

Simply Hired

In order to integrate with SimplyHired you need to submit your information at http://www.simplyhired.com/a/add-jobs/request?type=feed

Few guidelines for filling the form:

  • inclusion method – I have an XML feed of my jobs
  • feed format – Simply Hired XML
  • feed url – see below …

XML File URL: http://example.com/jobs/api/simply-hired
(Without permalinks: http://example.com/index.php?page_id=zxc&job_board=/jobs/api/simply-hired

Google Base

Register at http://base.google.com/base/ to upload your feeds to Google Base.

XML File URL: http://example.com/jobs/api/google-base
(Without permalinks: http://example.com/index.php?page_id=zxc&job_board=/jobs/api/google-base

Juju

Juju, also known as Job search engine, to submit your feeds go to http://www.job-search-engine.com/add-jobs/, scroll down to “Add Jobs in Bulk” and fill in the form. Check “I have a job feed” and supply your feeds URL.

XML File URL: http://example.com/jobs/api/juju
(Without permalinks: http://example.com/index.php?page_id=zxc&job_board=/jobs/api/juju

Posted in User Guide | 5 Comments

Twitter and Bit.ly

When a job is approved it can be sent to Twitter automatically.

First thing you need to do (if you haven’t already done so) is to register at http://twitter.com and http://bit.ly.

  1. After that, login to Bit.ly account and find you API key
  2. Go to dev.twitter.com sign in with your Twitter credentials, next click “Register an application” link
  3. Fill the form, it’s automatically accepted so Twitter guys probably don’t check it all, but still … keep it proffesional. One important thing here is to select “Read and Write” on “Default Access type”. Click “Register Application” and you’re done
  4. Now you will need 4 keys to make your app work. Go to “View Your Applications” and then click “Edit details” on your newly created app. Scroll down and copy into WPJobBoard -> Configuration -> Edit External Integrations, “Consumer Key” and “Consumer Secret”
  5. Next in the right sidebar click link “My access token” and again copy: “Access Token (oauth_token)” and “Access Token Secret (oauth_token_secret)” into the configuration
  6. Click “Save Changes”.

Next, you need to go to “Edit Job Posting Options” configuration panel and set:

  1. Check “Tweet Jobs” checkbox
  2. Enter “Tweet Template” if it’s empty. The default value for “Tweet Template” is “{title}, {url}, {category}, {type}”
  3. Click Save Changes

Now, all your jobs should be tweeted once they become active on the job board.

Posted in User Guide | 10 Comments