Skip to content

Instantly share code, notes, and snippets.

@robertscherer
Created March 11, 2014 13:57
Show Gist options
  • Save robertscherer/9486134 to your computer and use it in GitHub Desktop.
Save robertscherer/9486134 to your computer and use it in GitHub Desktop.
public function saveSitemap($tree, $parent_id = null, $sort = 0) {
$this->begin();
foreach($tree as $element) {
if(isset($element['children'])) {
$this->saveSitemap($element['children'], $element['id'], $sort);
}
// Save parent_id and sort
if (!$this->updateField($element['id'], 'parent_id', $parent_id)
|| !$this->updateField($element['id'], 'sort', ++$sort)
|| !$this->updatePageUrls()) {
$this->rollback();
return false;
} else {
}
}
$this->commit();
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment