Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba

multiple manymany DOM : sortable jointable problem


Go to End
Reply


634 Views

Avatar
El Mich

Community Member, 8 Posts

15 December 2011 at 10:10pm

Edited: 15/12/2011 10:15pm

Hello,
I have a setup where I 'tag' files with my product objects by a many_many, and in an other many_many I select which of these files should be shown on the product page. Like this:

class FileDecorator extends DataObjectDecorator {
    function extraStatics() {
        return array(
            'belongs_many_many' => array(
              'Files' => 'Product',
              'AttachedFiles' => 'Product'
            ));
    }
    
class Product extends DataObject {
    static $many_many = array(
        'Files' => 'File',
        'AttachedFiles' => 'File'
    );

for both relations I use the DOM, with sortable extension:

$FilesSelect = new ManyManyFileDataObjectManager(
        $this,
        'Files'
        'File'
        );

and for the AttachedFiles, I first get a list of all files (ID's) tagged with this product and use this as a filter in the where clause:

$TaggedFilesIdString = $this->getTaggedFilesIds();          
        $AttachedFilesSelect = new ManyManyFileDataObjectManager(
        $this,
        'AttachedFiles',
        'File',
        $sourceFilter = "File.ID in($TaggedFilesIdString));

Sortable extensions are configurated like this:

 SortableDataObject::add_sortable_many_many_relation("Product", "Files");
SortableDataObject::add_sortable_many_many_relation("Product", "AttachedFiles");

All works great, I can tag my files with products, I can sort these tagged files independently for each product, I can also select from the filtered list in the AttachedFiles DOM, but, if I change the sortorder on the AttachedFiles DOM it does not get stored.

I did notice that upon sorting the AttachedFiles, the SortOrder field on the Product_Files table is updated, instead of the SortOrder field on the Product_AttachedFiles join table.

How should I do this?
Thank you!