You are here:  » Job site

Support Forum



Job site

Submitted by marco@flapper on Tue, 2011-11-22 12:27 in

Hi,
I was trying to make a job site and wanted to use the Price field for the job hours so that a visitor can filter the search results so they get the jobs for the hours the seek to work.

In the datafeed I have for example this data:

<column name="jobs_hours"><![CDATA[32 - 40 uur]]></column>

I was thinking on replacing the 32-40 by just 40 but do you have another solution for this?

Submitted by support on Tue, 2011-11-22 12:48

Hi Marco,

You could have a go with an atlernative version of the tapestry_decimalise() function in includes/tapestry.php. Try something like this:

  function tapestry_decimalise($price)
  {
    $parts = explode(" ",$price);
    foreach($parts as $k => $v)
    {
      if (!is_numeric($v)) unset($parts[$k]);
    }
    return array_pop($parts);
  }

...and from your example value of "32 - 40 uurl" the above would return 40...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Tue, 2011-11-22 13:23

Hi,
I placed the code but it returns all the values in zero (0.00).

Submitted by support on Tue, 2011-11-22 13:41

Hi Marco,

I spotted the problem corrected version in the post above...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Tue, 2011-11-22 14:04

Hi,
I get 40.00 but what should I do to make it display without the decimals?

Submitted by support on Tue, 2011-11-22 14:11

Hi Marco,

Try the following dbmod.php script to convert the price field to INT instead of DECIMAL...

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            CHANGE `price` `price` INT(11) NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Tue, 2011-11-22 14:16

Thanks it worked just fine.

Submitted by marco@flapper on Thu, 2011-11-24 10:54

Hi,
added a new feed but this has the following texst values in the field for price Vast contract, onbepaalde tijd so now I get jobs that display with price = 0.

Is there a way to handle this?

Submitted by support on Thu, 2011-11-24 11:34

Hi Marco,

As the hours field is going through tapestry_decimalise() now you could always have a translation array in the function to return specific values for string constants like that. Have a go with:

  function tapestry_decimalise($price)
  {
    if ($price=="Vast contract") return "12";
    if ($price=="onbepaalde tijd") return "34";
    $parts = explode(" ",$price);
    foreach($parts as $k => $v)
    {
      if (!is_numeric($v)) unset($parts[$k]);
    }
    return array_pop($parts);
  }

...where 12 / 34 are the hours you want to use for Vast contract / onbepaalde tijd respectively...

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Thu, 2011-11-24 12:03

Hi,
I'm still getting zero. I used:

function tapestry_decimalise($price)
  {
    if ($price=="Vast contract, onbepaalde tijd") return "40";
    if ($price=="onbepaalde tijd") return "40";
    $parts = explode(" ",$price);
    foreach($parts as $k => $v)
    {
      if (!is_numeric($v)) unset($parts[$k]);
    }
    return array_pop($parts);
  }

Submitted by support on Thu, 2011-11-24 13:15

Hi Marco,

Perhaps a better alternative would be to default to 40 if the input value is not numeric? To have a go with this method, use something like:

function tapestry_decimalise($price)
  {
    if (!is_numeric($price)) return "40";
    $parts = explode(" ",$price);
    foreach($parts as $k => $v)
    {
      if (!is_numeric($v)) unset($parts[$k]);
    }
    return array_pop($parts);
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by marco@flapper on Thu, 2011-11-24 13:40

Thanks, that works.

Submitted by marco@flapper on Fri, 2011-11-25 15:10

Hi,
I want to use it with the wordpress plugin in a multisite. So the pt database will be in the same database as wordpress with a prefix like pt1

Can I use the dbmod.php script to convert the price field to INT instead of DECIMAL there in the same way?

<?php
  require("includes/common.php");
  $sql = "ALTER TABLE `".$config_databaseTablePrefix."products`
            CHANGE `price` `price` INT(11) NOT NULL";
  database_queryModify($sql,$result);
  print "Done.";
?>

Submitted by support on Fri, 2011-11-25 15:15

Hi Marco,

Yes, exactly the same - run the script from the installation folder of the Price Tapestry installation that the plugin is connected to rather than the root of the WordPress site, that's all you have to bear in mind...

Cheers,
David.
--
PriceTapestry.com