Answer the question
In order to leave comments, you need to log in
How to change order order?
You need to change the order of the menu items. They are sorted by the 'order' field, which has the unique status in the database.
It is necessary to make the functionality of changing the places of menu items - the item "contact" was in second place, became in first. Decided on the forehead first
public static function changeOrder($cur, $new) {
if ((isset($cur)) && (isset($new)) && ($cur !== $new)) {
$currentModel = parent::findOne($cur);
$newModel = parent::findOne($new);
$currentModel->order = $new;
$newModel->order = $cur;
if ($currentModel->save() && $newModel->save()) {
echo 'works';
} else {
var_dump($currentModel->errors);
var_dump($newModel->errors);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question