This project has moved and is read-only. For the latest updates, please go here.

Multiple custom sort orders for the same content items

Apr 21, 2014 at 3:00 AM
It seems that it isn't possible for a content item to be referenced by more than one custom sort order. Is that correct?

For example, if you have a list of "Product" items, and you want to have two custom sort orders: "Featured Products" and "Products under $20". It looks like you aren't able to place the same product in both lists.

Would it be easy to modify the custom sort feature to support this?
Apr 27, 2014 at 7:57 AM
That's a bug. Please file it and I'll fix it.
Apr 27, 2014 at 11:34 PM
Unfortunately, this is way more complicated to fix than anticipated. It will require changes in core, which means the fix will only work on the next version of Orchard.
Apr 28, 2014 at 3:59 PM
Thanks for looking into it. I opened this as a new issue: https://vandelay.codeplex.com/workitem/32. If you have any ideas on how you'd approach the implementation, I'd be happy to help with it.
Apr 29, 2014 at 10:07 PM
Actually, I was wrong: there is a very simple fix. Just remove the primary key constraint on Vandelay_Industries_CustomSortOrderRecord's Id column using SQL Management Studio. I'll integrate the change into the migration for new users.
Jan 10, 2015 at 11:09 PM
Did you apply the fix or should we apply the patch?
Jan 11, 2015 at 10:37 AM
Suggestion: PrimaryKey should exist but not on [Id] but on both [Id] & [CustomSortRecord_Id] columns.
Jul 8, 2015 at 6:31 PM
Did you ever get this to work?
Jul 9, 2015 at 10:07 AM
Yes, works perfect.
Jul 9, 2015 at 10:34 PM
How exactly did you set it up to do that? Did you do it in the migration or just and SQL script? I've tried setting a unique clustered index on the Id and CustomSortRecord_Id and that doesn't seem to work.
Jul 9, 2015 at 10:55 PM
I did not had the time for migration, sql script: remove existing pk and unique index and then add then new ones. If you are using Azure, only solution is to drop table and create it again with the right pk and index.
Jul 10, 2015 at 7:22 PM
Okay thanks for the advice there, this is what I did and it is still not working:
DROP TABLE Vandelay_Industries_CustomSortOrderRecord
CREATE TABLE Vandelay_Industries_CustomSortOrderRecord (
  Id int not null,
  CustomSortRecord_Id int not null,
  SortOrder int not null,
  primary key (Id, CustomSortRecord_Id)
);

ALTER TABLE [dbo].[Vandelay_Industries_CustomSortOrderRecord]  WITH CHECK ADD  CONSTRAINT [OrderToSort] FOREIGN KEY([CustomSortRecord_Id])
REFERENCES [dbo].[Vandelay_Industries_CustomSortRecord] ([Id])
Does that look right?