2
votes

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

  • AAA
    • BBB
      • CCC
      • CCC
    • BBB
      • CCC
    • CCC

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.

2
Please forgive my ignorance, but is this anything to do with programming? - Software Engineer
Sitecore is a content management system used by .NET developers. Generally the solution to any problem like this is the need to customise and extend Sitecore's core .NET implementation. So we'll find out if this has anything to do with programming if/when I get an answer. - Tom Troughton
In theory droptree should work with parameters too but in practice it does not work! Without custom coding to create a new control or "fix" an existing one, you could use validation on a Treelist control to restrict to a single selection only. Not ideal though. - jammykam

2 Answers

2
votes

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.
0
votes

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.