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
Related
In Sitecore, I built two custom multi-lists, where the second one depends on the first. The only issue is, that after selecting the first one, I have to save the item before the second multi-list filters the items.
My question somebody know how to create a two custom multi-list on Sitecore, where the second one filters automatically after selecting an item in the first (without save event), or which event can I override to do it?
It sounds like what you are looking for is some kind of front end event that you can use in the Sitecore backend to update a list based on another list selection without a save event. I don't think there is really anything out of the box for that..
Really what you should be doing (to do the 'sitecore' thing) would be to have your first selection (be it multi-list or whatever you like) simply point to a datasource item for another template item which is where your user can set the second option(s). I think you would benefit from taking a different approach like this rather than trying to customise Sitecore here.
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
So I am rather new to sitecore, and it's a topic that wasn't covered during my training. My questions is just to help point me to the correct term, or documentation on a method to do the following.
I have a definition item, with a ton of field groups, what I want to do is something like:
if Value of Field X is "yes" then collapse/hide Field X or Field Group X.
Does that make sense? Is it a validation rule? or some other kind of rules, is it a workflow I need to attach? Do you place it on just the field I want to hide, or the field that triggers the action?
I appreciate any guidance.
There is nothing out-of-the-box in Sitecore to achieve what you want but there is no reason you cannot create a composite custom field type to do this. The following articles will help you achieve this:
Creating a custom Sitecore Field
Getting to Know Sitecore: Custom Fields, Part 1
Create a new control, inheriting either from Droplist (if the comparison of the value is to be text based) or Droplink (for comparison of ID). You could add a parameter in the Source field of the control to specify what the values that trigger the hide should be.
The underlying control in the Content Editor is just a standard HTML select element. Add onchange events to the control and add your Javascript handler to hide the other controls. Since I could not find a way of adding additional custom css classes to the Sitecore controls, it would be best/easiest to hide all other controls in the same collapsible group after you control. This would mean you would need to group your controls better (or logically at least).
The Javascript will be something like this (the Content Editor uses the Prototype JS framework):
if ($(this).getValue() == 'no') {
// find the parent container of this control and then hide all the next siblings in the same group
$(this).up('.scEditorFieldMarker').nextSiblings('.scEditorFieldMarker').invoke('hide');
}
You can test this by running the above in the console, change out the keyword this with the id of your field, e.g. $('FIELD2292054').
What I am not sure about is how to trigger the hide on initial load, i.e. when someone returns to an existing item, it may be possible by adding to one of the pipelines, but would be better using a JS solution if possible. I'll have a think about this and get a proper code sample up over the next few days.
EDIT: You can add an event handler to sc:contenteditorupdated to handle the content editor being rel-oaded.
document.observe("sc:contenteditorupdated", myFunction);
I wrote up a blog post and put the code on GitHub if you are interested.
Not sure if you have come across Andy Uzick's this blog post.
He wisely talks about hiding fields in the Content Editor and has also created a Sitecore Module called Hide Field Template Extension which is hosted on the Sitecore Marketplace with the full source code to extend.
After reading through and trying the extension, I do feel that it will not completely resolve your issue (how you have described it in the question).
But it will give you:
A mid-term solution to hide a few unnecessary field that some content editors would not like to view.
Fields that are only required by administrators for admin purpose - to de-clutter these fields could be hidden.
Just one thing to bear in mind that it mentions in the requirements Sitecore 6.5 & 6.6. I have not tested it in Sitecore 7. If you are using Sitecore 7, which I think you are, one could modify the source code and make it work for Sitecore 7.
Have a look and share your findings.
Happy Sitecoring!
The client wants to be able to display, within a WFFM form, a list of Sitecore items (each item containing an image & some HTML text), each item next to a checkbox to allow the end user to pick one or more of these items.
Within the form designer, for this particular field, we would like to have an item selector which can be used by the content editor to pick and choose which items to display in the list.
Is this something feasible in WFFM? Are there examples of complex custom form fields that I could take a look at? Thanks!
I just found out that what I asked can be easily accomplished with the ChechboxList field type already provided by WFFM and some CSS styling to handle the content of each item.
Thanks and sorry for the post.
Can I populate a droplist in sitecore with a list of values by directly specifying them in the source field like Apples|Oranges|Grapes and have them show-up on the template instead of actually creating items for each value and then writing a query pointing to the parent?
There is no default functionality for this. The typical approach would be to create a folder containing items with each of these names, and set that folder as the source of a standard droplist field. But I would use droplink instead of droplist, because then you have strong references by ID rather than weak references by name, and those references appear in the links database.
Alternatively, you could probably achieve this by overriding the droplist control.
/sitecore/System/Dictionary might be a good home for the values you need to create in this context. Adding them to the Dictionary also makes them localizable and allows users to reference them as tokens in other fields if desired.
You might also find this article to be of interest. It goes into some detail about other uses for Dictionary items and Tokens.
Also, Sitecore's Reusing and Sharing Data guide has additional information on how to use Dictionary items and looks at other situations where you might want to inject simple values into items: