Свежайшие Пирожки от CakePHP по-русски

Полнейшее руководство CakePHP 1.2 на русском языке, горячие новости и полезные статьи

moveUp

Used to move a single node up the tree. You need to provide the ID of the element to be moved and a positive number of how many positions the node should be moved up. All child nodes will also be moved.

Here's an example of a controller action (in a controller named Categories) that moves a node up the tree:

Простой текст
  1. function moveup($title = null, $delta = null){
  2. $cat = $this->Category->findByTitle($title);
  3. if (empty($cat)) {
  4. $this->Session->setFlash('There is no category named ' . $title);
  5. $this->redirect(array('action' => 'index'), null, true);
  6. }
  7. $this->Category->id = $cat['Category']['id'];
  8. if ($delta > 0) {
  9. $this->Category->moveup($this->Category->id, abs($delta));
  10. } else {
  11. $this->Session->setFlash('Please provide a number of positions the category should be moved up.');
  12. }
  13. $this->redirect(array('action' => 'index'), null, true);
  14. }

For example, if you would like to move the category "Desserts" up one level up you would request /categories/moveup/Desserts/1.