N2S

Topic: Company Clouds on homepage (Top 20 Companies)

JOBBER VERSION: 1.5 beta 1 (20/08/2008)
FILES TO EDIT: page_home.php, /_templates/home.tpl, /css/screen.css

OPEN:page_home.php

Code:

FIND: 
    $html_title = $translations['homepage']['title'] . SITE_NAME;
    $template = 'index.tpl';

AFTER ADD:

// begin cloud
$companies = array();
    $sanitizer = new Sanitizer();
    $sql = 'SELECT DISTINCT company FROM jobs WHERE is_temp = 0 AND is_active = 1 ORDER BY Rand() ASC LIMIT 20';
    $comps = $db->QueryArray($sql);
    foreach ($comps as $company)
    {
        $sql = 'SELECT COUNT(id) AS nr
                       FROM jobs
                       WHERE company = "' . $company['company'] . '"';
        $nr = $db->QueryItem($sql);
        if ($nr < 2)
        {
            $tag_height = 1;
        }
        else if ($nr >= 2 && $nr < 3)
        {
            $tag_height = 2;
        }
        else if ($nr >= 3 && $nr < 4)
        {
            $tag_height = 3;
        }
        else if ($nr >= 4 && $nr < 5)
        {
            $tag_height = 4;
        }
        else if ($nr >= 5 && $nr < 6)
        {
            $tag_height = 5;
        }
        else if ($nr >= 6)
        {
            $tag_height = 6;
        }
       
        $companies[] = array('name' => $company['company'],
                             'varname' => $sanitizer->sanitize_title_with_dashes($company['company']),
                             'count' => $nr,
                             'tag_height' => $tag_height);
    }
    $smarty->assign('companies', $companies);
    $smarty->assign('companies_count', count($comps));
// end cloud

OPEN: /_templates/home.tpl

Code:

FIND:
                {/if}
                {if !$latest_jobs && !$most_applied_to_jobs}

BEFORE ADD:
            <div class="companycloud">
               <h3>Company Cloud</h3>
               <p class="names">{section name=tmp loop=$companies}
            <span class="company-tag-{$companies[tmp].tag_height}">
            <a href="{$BASE_URL}jobs-at/{$companies[tmp].varname}/">{$companies[tmp].name}</a>
            </span>
            {/section}
            <br />
            </p>
            <p class="clearfix viewmore"><a href="{$BASE_URL}companies/">View All &rarr;</a></p>   
            </div>

OPEN: /css/screen.css

Code:

ADD:
.companycloud{border:1px #eaeaea solid; /*margin-left:10px;*/ margin:20px 0 20px 10px; padding:10px;}
.companycloud h3{background:#f1f1f1 url(../images/bg.png) bottom repeat-x; display:block; font-family:Arial, Helvetica, sans-serif; padding:15px 10px; margin:0; font-weight:normal; color:#666; text-transform:uppercase; border-bottom:1px #ddd solid; font-size:1.2em; margin-bottom:20px;}
/* tag heights */
.company-tag-1 {font-size: 16px; !important}
.company-tag-2 {font-size: 18px; !important}
.company-tag-3 {font-size: 22px; !important}
.company-tag-4 {font-size: 26px; !important}
.company-tag-5 {font-size: 30px; !important}
.company-tag-6 {font-size: 34px; !important}
p.names a{color:#666;}
p.names a:hover{background:#555; color:#fff;}
p.viewmore a{margin-top:20px; background:#f1f1f1; padding:2px 5px; margin-left:00px; float:left;}
/* Auto Clearing Method ( Not for IE )
######################################## */
.clearfix:after
{
    content: "."; 
    display: block; 
    height: 0; 
    clear: both; 
    visibility: hidden;
}

OUTCOME:
http://i38.tinypic.com/1z5n1ps.jpg

*thanks to flakdesign
HIS SIDEBAR DEMO: http://www.hireme.sg
http://i36.tinypic.com/35ncylc.jpg
(I did not add mine to the sidebar because It did not work for me. I think there was a css conflict, and I dont want to spend time on one small imperfection. So I therefore placed it on the bottom of the home page.)

*Having problems?
Notice that I said "BEFORE ADD" for one of the instructions. Go back and see if that may be the problem.*

Last edited by N2S (2008-10-28 02:26:11)

http://i34.tinypic.com/2affofk.png

remstoffer

Re: Company Clouds on homepage (Top 20 Companies)

Hello N2S,

I am trying to include the tag cloud into my homepage of www.alquilomitiempo.com but I actually want to change the companies to the CITIES!!

I am not an expert at all with coding and so on so I just tried changing the word COMPANY and COMPANIES to CITY and CITIES. It seemed logical but ofcourse that doesn't work. It give me an error on 3 lines: 26, 53 and 54 which are:

26 = WHERE company = "' . $city['city'] . '"';
53 = $cities[] = array('name' => $city['city'],
54 = 'varname' => $sanitizer->sanitize_title_with_dashes($city['city']),

do you have a solution for this or would the cloud for the cities not be posible.

Thank you for your help if you can find the time to have a look at it.

Remco

benthomas1985

Re: Company Clouds on homepage (Top 20 Companies)

Hi remstoffer

To change it to Job types I just changed all the 'company' tags to 'title' in page_home.php

Although the cities are in a different table so this may not work.  Although it should be good for anything in the jobs table.

Use an editor like notepad++ which selects words all at the same time so you know you have replace every instance.

Ben

evertsemeijn

Re: Company Clouds on homepage (Top 20 Companies)

Anyone feel like changing this to display tags on the homepage? Want to include it to jobberbase release, bu can figure it out myself...

Tags tutorial can be found here: http://www.redjump.co.cc/2009/04/18/add … ing-a-job/

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