Added by anonymous on 2008-07-28 14:57:30 Download/View
- {
- // Make sure we have a valid resource (and only one!)
- {
- // What direction are we moving it?
- // Get resource information
- $resource->current();
- // Get the field we are going to swap with
- $field_for_swap = Resource_Model::factory()
- ->where('sort_order '.$direction.$field->sort_order)
- ->where('resource_id', $field->resource_id)
- ->orderby('sort_order', $sort)
- ->limit(1)
- ->get()
- ->current();
- // If we found a field to swap with, then let's update them
- {
- // Swap the values
- // Save the changes!
- $resource->save();
- $field_for_swap->save();
- }
- }
- }