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

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

moveDown

Used to move a single node down 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 down. All child nodes for the specified node will also be moved.

Here is an example of a controller action (in a controller named Categories) that moves a specified node down the tree:

Простой текст
  1. function movedown($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->moveDown($this->Category->id, abs($delta));
  10. } else {
  11. $this->Session->setFlash('Please provide the number of positions the field should be moved down.');
  12. }
  13. $this->redirect(array('action' => 'show'), null, true);
  14. }

For example, if you'd like to move the "Cookies" category one step down, you would request: /categories/movedown/Cookies/1.