Q: CakePHP ordered behavior with multiple foreign keys CakePHP does not have a built in mechanism for handling reordering of records, as far as I know. So, I'm using the Ordered Behavior that, as near as I can tell, is the defacto behavior for reordering in CakePHP.  So far it's working well as I add it to various models, however, I've got a situation I'm not sure how to deal with.
My model hierarchy is as follows.
Section > Heading > Category > Item
However, Items can be attached directly to sections:
Section > Item
The Item model's table has both category_id and section_id defined, though only one is actually used for any given record.
The ordered behavior has two parameters set when you set the model's $actsAs.  Here's the one for my Heading model:
var $actsAs = array('Ordered' => array('field' => 'order','foreign_key' => 'section_id'));

How should I define the $actsAs member for the Item model where it has two foreign keys section_id and category_id to ensure that the ordering/sequence is properly maintained?

A: I haven't tested this extensively, but with my first try this appears to be a workaround that will let me dynamically manage the ordering.  Inside of my ItemsController I've got the following actions:
    function moveup($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid id for Item', true));
        } else {
            $item = $this->Item->read(null, $id);

            if ($item['Item']['section_id'] != 0) {
                $this->Item->Behaviors->attach('Ordered', array('field' => 'order', 'foreign_key'=>'section_id'));
            } else {
                $this->Item->Behaviors->attach('Ordered', array('field' => 'order', 'foreign_key'=>'category_id'));
            }

            if ($this->Item->moveup($id)) {
                $this->Session->setFlash(__('Item moved up', true));
            } else {
                $this->Session->setFlash(__('Item move failed', true));
            }
        }

        $this->redirect($this->referer());
    }

    function movedown($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid id for Item', true));
        } else {
            $item = $this->Item->read(null, $id);

            if ($item['Item']['section_id'] != 0) {
                $this->Item->Behaviors->attach('Ordered', array('field' => 'order', 'foreign_key'=>'section_id'));
            } else {
                $this->Item->Behaviors->attach('Ordered', array('field' => 'order', 'foreign_key'=>'category_id'));
            }

            if ($this->Item->movedown($id)) {
                $this->Session->setFlash(__('Item moved down', true));
            } else {
                $this->Session->setFlash(__('Item move failed', true));
            }
        }

        $this->redirect($this->referer());
    }

My model doesn't set the ordered behavior (and thus the foreign_key) via the $actsAs member.  Instead, prior to any order manipulation, I determine the parent item type and attach the behavior, with appropriate foreign_key at run time.
