Skip to content

Commit

Permalink
insert real [ord] number when adding new page
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Sep 27, 2012
1 parent 040d171 commit fe199f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/AdminModule/presenters/PagesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function actionAdd($id_parent, $sibling=false){
$newid = PagesModel::addPage(array(
'id_parent' => intval($id_parent) ? intval($id_parent) : 0,
'lang' => $this->lang,
'ord' => 9999,
));
$this->redirect('edit#newpage', $newid);
}
Expand Down
6 changes: 5 additions & 1 deletion app/models/PagesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ public static function getPagesByMeta($key, $value){
public static function addPage($data){ //lang supplied in $data
if(!isset($data['published']))
$data['published'] = 0;


if(!isset($data['ord'])){
$data['ord'] = 1 + dibi::fetchSingle('SELECT max(ord) FROM pages WHERE lang=%s',$data['lang']," AND id_parent=%s",$data['id_parent']);
}

dibi::query('INSERT INTO pages', $data);
$new_page_id = dibi::insertId();

Expand Down

0 comments on commit fe199f2

Please sign in to comment.