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
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! :)
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
Related
I have a field called "Page Title" that is part of a base template that I called "Base Titles". All of my content pages inherit this base template. I would like to boost the Page Title field in my search results so that if the search term is found in that field it is scored higher than other matches.
I can't figure out how to do this. I found this blog post by John West. However that seems to suggest that in order to boost a field I have to edit a config file?
Is that correct? So there is no way within the Sitecore UI to edit boosting values for a field? It has to be done by a programmer in a config file?
There is no in-built functionality for this. But off the top of my head I guess it's possible to approximate it.
For example. If your content editors have access to the Templates section of the Sitecore tree you could extend the "Template Field" template. Add a numeric field called Boost.
Then on any field in a template they could assign a numeric value
When you write your query you could look up the assigned value from of the associated field in the template and use the Boost method to apply it to the predicate.
Of course there's a bunch of different variations on this approach. This is really just the bare bones.
Sounds like you have the makings of a good marketplace module on your hands.
In Sitecore I have a folder called Models, a folder called Products and a folder called Years under my home item. In Models I have a a list of products. Models has a multilist that points to the Years item as it's data source. Products has a multilist which points to Models as a data source. I need to also give Products a multipicker that points to Years however these dates can only be dates that are available for it's selected Models. I need something that can pretty much look at the multilist of items chosen by a multilist as a datasource. I'm not sure if this is something possible out of the box. The reason I want to do this rather than nesting these three folders is to avoid duplicating content but I'm not sure if I can get around this.
I do not know a way out of the box. But I can think of a way where you could extend the Multilist and add it as custom field. Then override the source property and manipulate the value on set.
Here is an example where this is done to allow relative queries:
http://sdn.sitecore.net/Scrapbook/Custom%20TreeList%20that%20supports%20query.aspx
You would need to be aware of the selected models by getting the values from the corresponding field (using ItemID property to load the current item) and once you have that you could set the source to the years root folder and use data source parameters to exclude the ones you don't need.
Here is a good post about what options you have on the data source:
http://getfishtank.ca/blog/treelist-data-source-hidden-functionality
Downside of this is that you need to save the item before the custom tree is aware of the selected models. Another downside is that you might have to validate selected years because if you make changes in the selected models then the selected years could be invalid.
Don't think there is an out of box option for having cascading fields similar to what you described. You may need a custom field. Here is the full documentation on how to create a custom field in Sitecore
http://sdn.sitecore.net/Articles/API/Creating%20a%20Composite%20Custom%20Field.aspx
I've made a field "Multilist with Search" in my solution. The point of this field is to add related articles to an article. I have set a source similar to this:
TemplateFilter={TemplateID}&StartSearchLocation=query:/path/to/list/of/items
I want make a search that finds a certain field value. For example, if I want to find the articleId on the searched article. Is there built-in support for this in Sitecore 7.2?
Is it possible to make a search like articleID:706453?
I guess it's not the most easiest solution you're looking for, but you can extend IDataSource in your code and use the type as value in the Source-textbox for the field you want to use it for. With IDataSource you just return an array of items that will be use for your field. You can query whatever item you want.
See the article from John West on the Sitecore blog: http://www.sitecore.net/nederland/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Sitecore-7-Custom-Classes-as-Data-Template-Field-Sources.aspx
Otherwise you can try this:
StartSearchLocation=query:/path/to/list/of/items/*[#articleID = '123']
Note that Sitecore queries can be slow.
Suppose Item A contains the link Item B would like to use as the source of its Droplist field. How can I achieve this? I have read the Sitecore Query documentation here and here. It appears to me that this is not achievable using Sitecore query, but I could be mistaken. Any help would be appreciated.
No this is not possible. To set the source of a droplist, you can either set the root path to an item which would make the droplist populate the sub-items or you can use Sitecore query to query for specific items based on your query. This is covered in the Data Definition Cookbook (PDF link) under 2.4.2.
I inherited a SharePoint 2007 site collection that has a myriad of subwebs.
To simplify things, though, imagine the following hierarchy:
SiteCollection SC
SiteCollection Site
SubWeb1
SubWeb2
SubWebs 1 and 2 were created from the same site template years ago. They each have a List called ProjTasks that contain the same fields as each other, and even have the same InternalName and Guid. These subWebs do not talk to each other, but they can share the same parent information from the SiteCollection.
What's the best way to update the field definitions across all of the subwebs for a given list?
For the kicker, my specific example is modifying a Choice type's list of choices. While you can usually manually edit a choice by setting one on each line, the only options I have for editing this specific field is changing the Column name and the description (I do not see options for changing the data type or choice options. Any thoughts?
Thank you in advance.
Go to SC > Site Settings > Site Columns.
Is your field listed there? You should be able to edit it and have the choices cascade down to the lists in your sub sites.
for the benefit of everyone who might experience this problem, i found this solution and it worked perfectly. :)