You are here:  » Category Hierarchy Mapping: change parent

Active Forum Topics


Category Hierarchy Mapping: change parent

Submitted by sirmanu on Wed, 2022-03-09 08:35 in

Hi David.

Hoy can I change the parent_id in "Category Hierarchy Mapping" for a specific category (ID).

Maybe we need a parent_id selector in categories_hierarchy_configure.php?

Thank you!

Submitted by support on Wed, 2022-03-09 09:47

Hi,

A change parent form is straight forward to add to the configuration page for a mapping.

Edit admin/categories_hierarchy_configure.php and look for the following code at line 37:

  $submit = (isset($_POST["submit"])?$_POST["submit"]:"");

...and REPLACE with:

  $submit = (isset($_POST["submit"])?$_POST["submit"]:"");
  if ($submit == "Change Parent")
  {
    $sql = "UPDATE `".$config_databaseTablePrefix."categories_hierarchy` SET parent = '".database_safe($_POST["newparent"])."' WHERE id='".database_safe($id)."'";
    database_queryModify($sql,$result);
    header("Location: categories_hierarchy_configure.php?id=".$category["id"]);
    exit();
  }

Then look for the following code beginning at (now) line 100:

  widget_formEnd();

...and REPLACE with:

  widget_formEnd();
  $sql = "SELECT id,name FROM `".$config_databaseTablePrefix."categories_hierarchy` WHERE id <> '".$category["id"]."' ORDER BY name";
  if (database_querySelect($sql,$rows))
  {
    widget_formBegin();
    $parents = array();
    foreach($rows as $row)
    {
      $parents[$row["id"]] = $row["name"];
    }
    widget_selectArray("","newparent",TRUE,$category["parent"],$parents,12);
    widget_formButtons(array("Change Parent"=>TRUE));
    widget_formEnd();
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by support on Wed, 2022-03-09 13:02

Hi,

I saw your thank you message in moderation but it didn't get applied to the forum i'm still having database issues but looks like you're up and running with this mod...

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Wed, 2022-03-09 15:41

Just thank you, again. Your solution it is working as expected.

Best software & support ever.

Have a nice day!