sitecore 7 multi datasource field

3.4k views Asked by At

I have a treelist field that I want to set the datasource to 3 folders p.e.:

/sitecore/Website/News/
/sitecore/Website/Events/
/sitecore/Website/Articles/

Under the website item there are more "folders".

I've searched and spent few hours trying different approaches but none seemed to work.

Is this possible? Do I need to extend the field?

Thank you in advance

2

There are 2 answers

4
Ahmed Okour On BEST ANSWER

You can use IncludeTemplatesForDisplay parameter to filter the items based on templates:

DataSource=/Sitecore/Content/Home&IncludeTemplatesForDisplay=News Folder,News,Event Folder,Event

IncludeTemplatesForDisplay parameter accepts comma separated templates names, you might need to include parent folder templates names too so that it appear in treelist.

Hope this helps

7
Zachary Kniebel On

A while back I wrote a blog post about the different ways you can control the Datasource of your multilist and treelist fields (with and without search). The third technique listed for fields with search is what I think you are looking for:

Search in two or more places of the content tree (Fields with Search):

StartSearchLocation={110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}&Filter=_path:110d559fdea542ea9c1c8a5df7e70ef9|_path:3d6658d8a0bf4e75b3e2d050fabcf4e1


For your implementation:

StartSearchLocation={Website.ID}&Filter=_path:[News.ID (guid form; no brackets)]|_path:[Events.ID (guid form; no brackets)]|_path:[Articles.ID (guid form; no brackets)]


Search in two or more places of the content tree (Fields without Search):

If you are using a Multilist field (without search) then I would do the following:

DataSource=/path/to/source/1|/path/to/source/2


For your implementation:

DataSource=/sitecore/website/news|/sitecore/website/events|/sitecore/website/articles


I would also add that the Treelist with Search field has been deprecated in later versions of Sitecore 7, so if that is the field that you are using then I advise changing to the Multilist with Search field. If you are using a standard Treelist field, then Ahmed's answer may be viable as well, depending on your use case.

Let me know if you have any questions. Good luck, and happy coding! :)