7940 Posts in 1543 Topics by 946 members
Page: 1 2
|Go to End|
15 April 2010 at 1:00pm
I have MyPage with many_many relation, let's say Items=>Item, where Item is a DataObject.
In _config.php I have SortableDataObject::add_sortable_class('Item');
Now it used to allow me to drag&drop SortOrder of the Item on each MyPage page. It was useful because I have many MyPage pages and only need one order for Item.
After the update to the trunk DOM and the latest SS drag&drop checkbox is not available/visible at all.
15 April 2010 at 4:56pm
Right, because it's many_many, so you need to register it using add_many_many_sortable_relation().
15 April 2010 at 9:18pm
From what I see it's not what I need. add_many_many_sortable_relation adds SortOrder to a new table MyPage_Item, hence SortOrder is personalized for each MyPage page. But in my case I need the old way, where there's one SortOrder hold in a table Item. This is maybe unusual, so let me show you a sample (I'm really using it this way on my site):
On my website a have a list of categories (Items) the user can use to filter Products (MyPage pages).
Let's say: Category_A, Category_B, Category_C, Category_D. The list of categories is the same for each Product, so it doesn't make sense to order this list on each MyPage page (it still makes sense to keep SortOrder in Item, I want to keep the list of categories customizable). However, I still need many_many relation, because each Product is linked to one or more of categories. For example Product_A (MyPage) belongs to Category_A, Category_D. Product_B (MyPage also) is linked to Category_A, Category_B, Category_C and so on. To keep it flexible I need to be able to add Category_E, for example after Category_B, I would get: Category_A, Category_E, Category_B, Category_C, Category_D. I don't want to sort categories for example alphabetically because in my case it's better to sort them by marketing priorities rather than other criteria. Also for obvious reasons (lots of ManyPage pages) it doesn't make sense to set up the same order (Category_A, Category_E, Category_B, Category_C, Category_D) over and over on each MyPage page (add_many_many_sortable_relation).
For a similar case take a look at http://www.ea.com/ They have a list of categories for Platform (Xbox 360, Wii, ....) and they don't sort this list alphabetically (in the above sample Platforms are Items). They sort it by importance and it's customizable (they were able to add iPad recently;). On the other hand each game (MyPage) is linked to one or more platforms (many_many).
This is possible there's some other relation in DOM I don't understand but I'm pretty sure add_many_many_sortable_relation is not a solution (and I've tested it). Also I simplified the example because additionally for each Item/category I hold more fields than just a name. The important thing is the SortOrder worked exactly as I wanted in previous versions of DOM (was it not intended)?
15 April 2010 at 11:49pm
So you want to be able to set a Sort Order for your Category data objects, site-wide rather than per MyPage?
I'm not 100% certain I'm understanding you. If I am, you could create a 'SortOrder' or 'Priority' property directly on your Category data objects themselves, and then use this to help you sort whenever you're retrieving MyPages? Rather than retrieving MyPages you could return your Categories sorted via 'Priority' and then retrieve the MyPages linked to each.
Wouldn't really have much to do with the DOM module? If you wanted the categories selected for a MyPage to be sorted according to their Priority in the DOM you would just add that field to the Sort param in the initial DOM call.
16 April 2010 at 12:13am
In general it's a matter of convenience and flexibility. It would be just perfect if ManyManyDataObjectManager could handle both sorting methods (the old method using SortOrder from my DataObjects and the new one using page/DataObject combination).
add_sortable_class adds SortOrder to my category Data Objects. However right now without drag&drop enabled for this sorting my users have to re-order categories manually (the need to click the category and set up the number for SortOrder). Moreover i need the existing many_many relation because on each MyPage page I select a different set of DataObjects (each DataObject has a checkbox) - so each MyPage page can be linked to a different set of categories.
Having two places in the cms: one to set the order of categories and second one on each MyPage to select from categories would be a lot of hassle for my users.
Hope I didn't complicate the description too much, cause in practice it's very simple.
16 April 2010 at 2:38am
Quarx, can you update from the trunk and try now?
16 April 2010 at 3:28am
Wow, problem solved, this is exactly what I need Thank you, UncleCheese!
Page: 1 2
|Go to Top|