Tom Troughton
Tom Troughton

Reputation: 4325

Sitecore field for selecting link from folder structure defined by author

Working on a Sitecore 6.6 build I'm allowing authors to create items with the following structure:

Here AAA, BBB, CCC are different templates. Notice that AAA allows items of BBB or CCC, and BBB only allows CCC.

I now require a link field on a template with source root set to AAA, where the author may only select a single item of template CCC. But crucially I want the 'folder' structure (defined by BBB) to be preserved visually.

I can't use a DropLink because the item list is flattened.

As far as I can tell I can't use a DropTree because I can't stop the author selecting items of type BBB.

If I was offering a multi-select I could use a TreeList with a DataSource and work with its paramters (ExcludeTemplatesForSelection etc). But I only want a single item selected.

It would appear that Grouped DropLink is exactly what I'm looking for but it appears to be buggy. I may be misunderstanding though so your guidance would be much appreciated. The query below looks correct to me but presents a strange list of options where some items of BBB are selectable.

query:/sitecore/content/home/AAA//*[@@templateid='{CCC}']

Help much appreciated.

Upvotes: 2

Views: 250

Answers (2)

Zachary Kniebel
Zachary Kniebel

Reputation: 4784

I would try to adjust your query to the following:

query:/sitecore/content/home/AAA//*[@@templateid='{CCC}'][@@templateid!='{BBB}']

I know that it is redundant, but I would give it a try and see what happens. Regardless, you should open up a Sitecore support ticket for the issue.

Upvotes: 0

Rian
Rian

Reputation: 146

I would go for the Treelist (or even TreelistEx) as you suggested, but use a custom validator on the field where you specify that the field can only contain 1 guid. Make the error level high enough so non-admin users can't save the item when the field value is faulty. FatalError would be your best bet.

ValidatorResult.CriticalError   // The validator resulted in a critical error. The user will be warned before saving.
ValidatorResult.Error           // The validator resulted in an error.
ValidatorResult.FatalError      // The validator resulted in a fatal error. The user cannot save before the error has been resolved.
ValidatorResult.Suggestion      // The validator resulted in a suggestion.
ValidatorResult.Unknown         // The validator has not yet evaluated.
ValidatorResult.Valid           // The validator has evaluated and is valid.
ValidatorResult.Warning         // The validator resulted in a warning.

Upvotes: 2

Related Questions