Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple DataSource for Treelist

Tags:

sitecore

Quick question... I've got a treelist and I want the query to pull from multiple folders of my Content Tree. How can I set select from multiple datasources? I haven't found much on this, and I wonder if it has to do with changing the type of query I'm using. Right now, I have this query in the template for this particular item's treelist:

DataSource=/Sitecore/Content/Home/Home Root/Industries/&IncludeTemplatesForDisplay=Industry Item,Additional Resources Grouping,Additional Resources Item&IncludeTemplatesForSelection=Industry Item,Additional Resources Grouping,Additional Resources Item

I basically want to replicate the query above, but also pull from /Sitecore/Content/Home/Home Root/Products

Any suggestions for how to accomplish this?

like image 602
ndisdabest Avatar asked Feb 21 '23 17:02

ndisdabest


2 Answers

I don't think this supports multiple datasource paths, but as this SDN forum thread suggests (from John West) you can maybe tap into the getLookupSourceItems pipeline.

You could also create a custom Treelist that extend the built-in one and expose this functionality on your new one. You can use ILSpy to de-compile the current one.

like image 86
Mark Ursino Avatar answered Mar 11 '23 11:03

Mark Ursino


This is obviously SUPER late but for future reference I guess. I just had a similar question myself and found this and found what I think is a solution (at least in Sitecore 6.4).

You have the choice to 'ExcludeItemsForDisplay' as well that takes a list of ID's. If you backtrack one level to

"DataSource=/Sitecore/Content/Home/Home Root"

And Add "ExcludeItemsForDisplay= {ID of folders to ignore}, {the long ID that appears at the top of Quick Info}, {etc}", you should be able to exclude any folders you DON'T want to appear and only keep the ones you want.

IncludeItemsForDisplay is a bit too restrictive (and by a bit I mean a lot) to use unless you have only a handful of things you want to be available.

So hopefully this helps with any future problems. (Or the same problem if you hacked it in previously)

Your new Source not including the actual ID's of course:

DataSource=/Sitecore/Content/Home/Home Root&IncludeTemplatesForDisplay=Industry Item,Additional Resources Grouping,Additional Resources Item&IncludeTemplatesForSelection=Industry Item,Additional Resources Grouping,Additional Resources Item&ExcludeItemsForDisplay={12345678-1234-1234-123456789}, {#####-####-####}, {### etc}

I hope this helps (at least the next person that may come across the same question).

And also as a side note, as manually changing the Exclude sounds frustrating on a system that may change, your Folders also have templates that can be included in the IncludeTemplates. So if you give your Industries and Products special Folder Templates those can also be added to the IncludeTemplatesForDisplay String. Achieving hopefully the same more maintainable effect. I haven't tested this though.

like image 36
Reafexus Avatar answered Mar 11 '23 12:03

Reafexus