[SOLVED] Jobs Module : Sorting out Job ID

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
dinmix
Forum Members
Forum Members
Posts: 29
Joined: Sun May 06, 2007 2:49 pm

[SOLVED] Jobs Module : Sorting out Job ID

Post by dinmix »

I've problem sorting out Job ID. I've Jobs in different department and in each department, the jobs have to be sorted out in order of importance. I I've tried the following but its still not sorting.

{cms_module module="Jobs" sortby="job_id"}
{cms_module module="Jobs" sortby="job_hrid"}
{cms_module module="Jobs" sortby="jobs_id"}
{cms_module module="Jobs" sortby="jobs_hrid"}

I've checked the table in the database and figured out that the ID field is called "hrid". Hence I tried the above, but yet its still not working. Can anyone help by checking out if I got it right. I've found this post. http://forum.cmsmadesimple.org/index.ph ... 386.0.html but apparently still not working for me. Is due to the jobs in different department? Does anyone have the same problem?
Last edited by Anonymous on Thu Feb 07, 2008 8:35 am, edited 1 time in total.
Duketown

Re: Jobs Module : Sorting out Job ID

Post by Duketown »

I haven't got the Jobs module installed, but from what I read in the source, it might be that you have to include the table name in which the field resides. So have you tried something like:
{cms_module module="Jobs" sortby="mn.job_id"}

What helps me sometimes is to include a debug statement. I hope you are a bit familiar with PHP  ;).
Insert after line 134 in action.default.php the following:
echo 'DEBUG: result = '.$db->ErrorMsg().'  '.$db->sql.''; #die();
Save and run again. This will return in the front end the sql query used. Maybe you can derive an error from the statement generated.

Succes.
dinmix
Forum Members
Forum Members
Posts: 29
Joined: Sun May 06, 2007 2:49 pm

[SOLVED] Re: Jobs Module : Sorting out Job ID

Post by dinmix »

That really helps! Thank you sooo much for the tip. No, I am not familiar with PHP, still figuring out. Anyway, as I am not sure if there is anything wrong with the SQL syntax. I went to execute the query in mySQL and the result doesnt sort out until i removed the ' ' in between job_hrid. Next, I've checked the PHP in action.default.php and remove the ' ' in line 96. It work!!  ;D

I am not sure if this is the correct way of doing things though, but it work for me. My ID is sorted out by numbers and I've tried to sort out by alphanumeric as well and it works. is Here is the code for all to see.

In line 96, of action.default.php, remove ' '  in between:
$query .= "ORDER BY '" . str_replace("'", '', str_replace(';', '', $params['sortby'])) . "' ";

it should read something like the one below:
$query .= "ORDER BY " . str_replace("'", '', str_replace(';', '', $params['sortby'])) . " ";

The param remain as:
{cms_module module='Jobs' sortby='job_hrid'}

Not sure why it work this way but any PHP guru reading this might want to explain.


din
Last edited by Anonymous on Thu Feb 07, 2008 8:36 am, edited 1 time in total.
Post Reply

Return to “CMSMS Core”