You are here:  » Inline Editor


Inline Editor

Submitted by stevewales20 on Tue, 2013-08-20 15:05 in

Hi David,

I trust the past few days without me asking questions have been bliss :)

So i've nearly perfected a login/inline editor for the site. Currently it updates the products table, which of course is useless after import.

So i'm thinking how it would be best to implement this. Perhaps check if the name is within the products map? and if so then add in the new description? or would it be best to do it separately with text files, just means a nightmare maintaining that way.

Some guidance/advice is all i'm after thanks.

Steve

Submitted by support on Tue, 2013-08-20 17:16

Hi Steve,

Yes - that would be the thing to do. Upon the "Save" action of your inline editor handle the process something like this, assuming product name in $name and description in $description:

$sql = "SELECT id FROM `".$config_databaseTablePrefix."productsmap` WHERE name='".database_safe($name)."'";
if (database_querySelect($sql,$rows))
{
  $sql = "UPDATE `".$config_databaseTablePrefix."productsmap` SET description = '".database_safe($description)."' WHERE id='".$rows[0]["id"]."'";
}
else
{
  $sql = "INSERT INTO `".$config_databaseTablePrefix."productsmap` SET name='".database_safe($name)."',description = '".database_safe($description)."'";
}
database_queryModify($sql,$result);

So in other words, update the existing productsmap table if one exists, else create a new one. You could follow that by updating the products table by name to avoid having to wait for the next import of course (which sounds like it's already in place anyway)...

Cheers,
David.
--
PriceTapestry.com

Submitted by stevewales20 on Tue, 2013-08-20 17:38

Great stuff once again!

Much appreciated.

Steve