0
votes

In my Sitecore MVC project, is it possible to define a template for a Sitecore item in such a way that the content item is linked to some number of "sub-items"?

For example, say I want to define two templates - one called User and another called UserGroup.

  • A User has two fields: Name and Age.
  • A UserGroup has three fields: User #1, User #2, and User #3.

Two questions:

  1. The User template would make use of the Single-line text and Integer field types. But for UserGroup, what types would be used for the User1 field (for instance)? Could I use User as a type? If not, does it make sense to store a GUID which points to the individual User content items that I want to reference?

  2. Is this approach considered an anti-pattern? Is it possible to pull off something like this by nesting the content items inside of each other in the Sitecore content tree? If so, how would the template have to be configured?

1

1 Answers

1
votes
  1. For the User #1, User #2, and User #3 you can use a drop link field. The datasource will point to the parent item of User items. User is not a type, is an template. You can consider User as a class and items of type User are objects.

I suggest you to download launch Sitecore from http://launchsitecore.net/en/download and install it on a clean solution to see how others are structuring items in Sitecore.

Update

You can have next structure

enter image description here

User #1 , User #2 and User #3 have datasources: ./

If one user can be assign to multiple user groups I suggest to put all users under a global item and the User #1 , User #2 and User #3 will point to that item.