arturs

Topic: You might be interested in the foloving jobs...

How would be possible to include 'you might be interested in the foloving jobs' - link to 5 or 10 similar jobs or newest from the same category?

flakdesign

Re: You might be interested in the foloving jobs...

Hey,

In hireme.sg, i used the following to display similar jobs

page_job.php

Add the following line of code

Code:
$smarty->assign('similarjobs', $job->GetJobsByName($info['title'], 10));

And in Class.job.php

Add

Code:

public function GetJobsByName($jobname = false,$limit = false)
    {
        global $db;
        
        if (strstr($jobname, ' ') || strstr($jobname, '  '))
        {
            $tmp = explode(' ', $jobname);
            $kw1 = $tmp[0];
            $kw2 = $tmp[1];
            if ($kw1 == '')
                {
                    $kw1 = $kw2;
                    $kw2 = '';
                }
        }
        else{$kw1= '';}
        
        $jobs = array();
        $conditions ='';
        if ($kw1 !='' && $kw2 !='')
        {
            $conditions .=' AND title LIKE "%' . $kw1 . '%" OR title LIKE "%' . $kw2 .'"';
        }
        else
        {
            $conditions .=' AND title LIKE "%' . $jobname . '%"';
        }
        if ($limit > 0)
        {
            $sql_limit = 'LIMIT ' . $limit;
        }
        else
        {
                $sql_limit = '';        //Edited by vinay@artminister.com
        }
        $sql = 'SELECT id
                       FROM jobs
                       WHERE 1 ' . $conditions . ' AND is_temp = 0 AND is_active = 1
                       ORDER BY created_on DESC ' . $sql_limit;
        $result = $db->query($sql);
        while ($row = $result->fetch_assoc())
        {
            $current_job = new Job($row['id']);
            $jobs[] = $current_job->GetInfo();
        }
        return $jobs;
    }

And in job-details.tpl

Add

Code:

{if $similarjobs}
<h2 class="similarjob">You might also be interested in the following jobs</h2>
    <ul class="listingjobs">
    {foreach item=job from=$similarjobs}
        <li><a href="{$BASE_URL}job/{$job.id}/{$job.url_title}/" title="{$job.title}">{$job.title|lower}</a></li>
    {/foreach}
    {/if}
    </ul>

I know its not the best solution, but just a quick one.

regards
vinay

Last edited by flakdesign (2008-08-20 15:15:19)

arturs

Re: You might be interested in the foloving jobs...

Fatal error: Smarty error: [in job-details.tpl line 141]: syntax error: mismatched tag {/if}. (Smarty_Compiler.class.php, line 2284) in /home/-httpd/darbadiena.lv/_includes/smarty/libs/Smarty.class.php on line 1088

dont know whats wrong...

flakdesign

Re: You might be interested in the foloving jobs...

Oops, missed an {if} tag, Fixed the code in job-details.tpl

arturs

Re: You might be interested in the foloving jobs...

Thanks, now it should be OK, just dont know why it is not showing anything. Anyway, thanks a lot, willl try to hack this.

evertsemeijn

Re: You might be interested in the foloving jobs...

Small fix. Put the </ul> into the {if} so when there are no similar jobs the closing tag (without opening tag) won't be written and removed {$job.url_title} from the URL, because it is not necessary.

Code:
{if $similarjobs}
    <h2 class="similarjob">You might also be interested in the following jobs</h2>
    <ul class="listingjobs">
    {foreach item=job from=$similarjobs}
        <li><a href="{$BASE_URL}job/{$job.id}/" title="{$job.title}">{$job.title|lower}</a></li>
    {/foreach}
    </ul>
{/if}

Last edited by evertsemeijn (2009-02-07 12:37:10)

Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes

evertsemeijn

Re: You might be interested in the foloving jobs...

And how do I prevent the current job from beinging displayed in the list? Because at the moment they do :S

Member of Jobberbase Development Team - Templates/Usability :: Looking for installation and/or custom design? :: Beautiful Wordpress themes