Development

Sitecore Tip: Treelist Source

I am sure you have plenty of other posts regarding using Datasource=… in the source for a TreeList field in Sitecore.  However, there is some important information that is missing in all of the posts that I have read.  There is some quirkiness to using a Datasource in Sitecore as the source for a treelist.  If you are trying to limit by template, be sure to include all templates that are in the hierarchy of your content.

For example, assume you are trying to find news that is in different sections of a site.  Assume the structure is something like news/year/month/newsitem.  Assume year and month are both folders or a custom template, but you want to populate a treelist with being able to select news from anywhere in the site (say for a featured article).

You would think that the following would be sufficient:

You may be right, or you may be spending the next few hours of your life never getting that time back.  To be 100% safe include the folders as such:

This assumes that the year and month templates are just the standard folder.  If year and month are both custom templates, include those as well.  Great, but now I have a bunch of stuff I don’t want to allow to be selected.  Following the existing posts add the following:

The above now states that you can see the items that have a News template or a Folder template, but you cannot select them.  Great all set right?  Maybe, but let’s just be 100% certain.  Alex has a post with another potential problem, where the links are not registered: Treelist Not Registering Links in Sitecore.  One final tweak brings us to this:

NOTE: This is just structure for this simple example.

Additional References:

Add Comment...

Your email address will not be published.
Fields marked * are required

About us

We are experts in creating dynamic solutions in web and creative disciplines that enable our clients to realize broad success. Our desire for innovative and usable solutions drive a passion of continual improvement that leads to a constant stream of more intuitive and streamlined results.

Visit

Search

Social