Before digging into my explanation i will summarize my question:
How do I provide the user (editor) with a user-friendly possibility to select a datasource item for sublayouts that are preset on the standard values?
My situation is as follows:
I have a page template, with pre-defined layout on the standard values.
Let's say the layout consists of:
one placeholder "wrapper"
one sublayout "content"
This sublayout is pre-defined on my page template, but can also be placed in the placeholder using the Page Editor.
It needs to have a datasource item that defines a Title and Body value.
Now, if a user adds this sublayout to the placeholder using the Page Editor, he will get a nice interface to select or create the datasource item (see screenshot).
However, if the sublayout was pre-defined on the standard values, it will be added without datasource (I can't pre-set the data source in the standard values because it's still unknown by then).
At that point there seems to be no way to get to that nice interface for selecting or creating a datasource item.
Ideally I want to be able to add a field to my template that can hold a datasource item which the user can select/create using the nice interface. I looked at the datasource field type, which could be an alternative, but it's still not exactly what I want.
Bare in mind that the content sublayout is just an example.
I understand that in that specific case I could solve it by always adding a title/body field to the template which hold the values if there is no datasource, but for my real world problem that won't suffice.
I don't have a whole lot of experience with the Page Editor (with the new way of working with it) so I would like to get some advice on this subject.
According to what you said here:
Ideally I want to be able to add a field to my template that can hold a datasource item which the user can select/create using the nice interface. I looked at the datasource field type, which could be an alternative, but it's still not exactly what I want.
It seems you want an intuitive data source selector interface in the CMS shell similar to the Page Editor-based UI.
Quick answer: Simply put, there's nothing that does this for you in Sitecore.
Longer answer: There are still some options for you, e.g.
Define a global "dummy" data source and set that to be the data source set in in Presentation > Layout Details of the template's standard values. So every time you create a new page, it will always point to that dummy value to show something.
From here you can do a few things:
If the user must use the shell UI and not Page Editor, they can simply create another data source item for the specific page and update that page to point to it using the existing native interface in Layout Details.
Another option is to write an event handler, say for item:created or similar that when you create an item, auto-create a corresponding data source item for this specific page (whether this auto-created item be a sub-items or global item...) then programmatically set this to be the data source. A similar concept is shown in this video by Nick Wesselman: http://www.techphoria414.com/Blog/2012/May/Sitecore_Page_Editor_Unleashed
Related
I am creating a Sitecore MVC site for a client and I need to create page that will list news articles for the company.
So far, I have created items that use a shared data template called “Article,” and I also have a sublayout (a view rendering) called “Article” that will display these items.
For the list itself, my plan was to create another component (a sublayout) call “News_List”, and to put a placeholder in it called “List”.
My question is this: can I allow the author to insert articles (e.g., N items of type “Article”) into this placeholder via the page editor?
Will SC allow you to insert multiple instances of the same component into a placeholder? Will this break anything?
I believe this is a pretty common question but I have not found a definitive answer. Thanks in advance…!
You can insert as many components (of the same type) in your placeholder as you want.. Just make sure to put the placeholder settings correctly and give it a decent name (not just "list" ;))
But are you sure you want to do this? Your editors will manually need to create a list of components for each article they want to add on the page. Doesn't sound to be very user (editor) friendly.. Maybe you should consider creating a list component that can get a list of articles as a datasource and show those. Or even select them automatically (but that might be not according to your business case)..
Yes, authors can add multiple instances of the same component into a single placeholder.
Assuming that the code of the component doesn't do any stupid things it's absolutely ok to do this.
I have a certain item which uses a sublayout sub1. The item created with this sublayout has a field "Switch Columns" which i want to remove or hide (or hide/remove the section "Columned Grid" if possible) . Note that i do not want every item of that template to hide the field; just the items using sub1 (since the template is being used by different sublayouts).
Is there a way to do this via code in the ascx file of the sublayout ?
You can solve by using an extra layer inherit.
Create 2 set of template fields:
Template field minimal set
Template fields with addition fields.
sub1 Inheritance from the Template field minimal set
other layouts use a template with Inheritance from the minimal set and the addition field.
maybe this is also usable:
For Hide in the Content editor.
You can deny "Field Read" for a role/user on your Template Field or Section item.
See https://community.sitecore.net/developers/f/8/t/2113
You can hide fields in the Content Editor with a custom processor in the getContentEditorFields, see this post:
http://ctor.io/hide-fields-in-the-sitecore-content-editor/
But as other answers suggested, I would overthink your approach. Personally I would either use two separate Sublayouts (with different number of columns where you can easily swap them later without loosing it's datsource) or use this as a rendering parameter.
No, that is not possible. When viewing an item in content editor, your sublayout is not loaded. I would recommend that you rethink your architecture. This sort of field should probably be a rendering parameter. Alternatively, you could create a separate template to act as the data source for those sublayouts.
Maybe a custom pipeline for the content editor? If you tap into the <renderContentEditor> pipeline, you may be able to inspect the item's presentation, sniff out the sublayout, and inject some JavaScript to hide the panel.
In my content tree, I have "Folder" items that have no presentation, but have all the insert options on them. How would you be able to use the "Insert Page" button in the ribbon to insert a new content item in the right part of the tree?
For Example:
I have my home page Content(Folder)/Home.item
All of my insert options are on Content(Folder), how do I add a new Home.item type without nesting it under Home.item?
In order to be able to use the Insert Page button, the item you are inserting under must have Presentation defined. It doesn't need to have components added, and I've worked round this before by simply define a "blank" layout and setting it on those items. Maybe create yourself a new template (inheriting from Folder) and then set Layout on that. But, this is a workaround at best. You can only "Insert Page" below the current page you are on, so you would essentially have to navigate to a blank page in order to create the sibling.
From what you have stated, it sounds like you may want to re-think where your Insert Options have been set and your content structure, i.e. why would you want create another Home item? Creating so will require set-up of another <site> and related config. You probably also want to separate those sites out with other settings, there is some good example of multi-site structure in this blog post. If you go down this route look into using Branch Templates. But, difficult to know what you are doing without context...
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!
I'm working on a Sitecore (6.4.0.101124) site that has two templates used for the home page. These have a very similar structure - the big difference between them is that they each have one different sublayout in the Controls section of the Presentation Details of the Standard Values. My understanding is that when the template is changed on an item the standard values of the template should be applied to that item. However, when the content editors change the template the presentation details remain the same until I go in and change them.
So this means that either I misunderstand how this is supposed to work, or something wonky is happening. This is a very similar problem to what's discussed in this thread, but the answers given don't seem to apply since this item was not created using a branch template.
Has anyone had a similar experience with this (and solved it)? Am I way off base in how this is supposed to work?
You write:
My understanding is that when the template is changed on an item the standard values of the template should be applied to that item.
This is only true if a field has not been edited. Once a field for an item has been edited, the edited value takes precedence over the default. Changing the template to one that has different Standard Values will only have an impact if the field has not been touched, or if the user resets the field to the default value using the Fields Reset button. (Note that manually clearing the field will not do the trick. Sitecore will store an empty string, which will override the Standard Value. By using the Reset button, you set the field to a Database Null, which causes the Standard Value to be used.)
You can tell if a field has been edited by checking for the text "standard value" next to the field in the Content Editor:
Sitecore 6.4.0 and Layout Deltas
Things are more complex with the Renderings field on Sitecore 6.4.0 and above, because Sitecore introduced a feature called "Layout Deltas" with this release. Before Layout Deltas, if you edited the presentation details of an item, Sitecore would copy the layout information from the "Renderings" field of Standard Values into the item's Renderings field, which had the consequence that any subsequent change to Standard Values Renderings would have no effect on the display of this item.
This functionality made it difficult to manage changes to presentation, since a minor change to a detail of presentation on an individual item, such as adding conditional rendering logic, would break the inheritance from Standard Values. If if was necessary to change the presentation of a class of items, it was necessary to first change Standard Values, and then to make the same change to every item that modified presentation.
With Sitecore 6.4's Layout Deltas, if you modify the presentation of an item, just the change is stored in the item's Renderings field, rather than a complete copy of the Standard Values rendering. This change, or delta, information is applied on top of the Standard Values Renderings information, so that modifications to Standard Values layouts are applied to all inheriting items, not just ones with unmodified presentation.
It sounds like your content editors have made a modification to the presentation of the item. When the template is switched, this change is being applied on top of the new template. You can confirm this by checking for the [Standard Values] text next to the Renderings field of the item in question.
The template has values, but what carries the values to the items that are created using that template is in the standard values item. Now, that being said, each field on an item that is created from that template has a flag that says whether or not its using template standard values. If the presentation details are NOT flagged as using standard values still, then its not going to cascade down the updates to the items.
Now.. to be sure that you understand the difference between a branch and a template.. a branch is sort of a "model" of how you can create an item. It is NOT going to cascade changes down when you make changes to the branch item at all. Items will inherit values from their TEMPLATE standard values. The branch values inherit only upon item creation.
EDIT: By the way, I should add that if you turn on the gutter on the left to show presentation overridden, you can see if the presentation values are standard values or not. If you see the icon, then you know the item is not currently using standard values.
I got to this question because I had a field across hundreds of pages which I needed to change. It was not shared to begin with. I tried setting the field to Shared & Unversioned within the template but that did not cause it to change everywhere when I made changes.
I then proceeded to set a Standard Value in the template to what I wanted the field to be, and then selected Versions -> Fields -> Reset after highlighting the Standard Value. The first time I did this, it reset the field to blank. Then I did it again and the field changed on every page which used that particular field. Hope this helps. It seems if you already have a field which wasn't shared to begin with, you need to do a standard value reset to it.