Sortorder of Inherited Templates

2019-06-21 11:14发布

问题:

Using Sitecore 6.6 we are constructing some templates that inherit many base templates. This is great for reuse and standardizing our code, as all the fields are stored in a constants file for easy reference. However, we seem to be unable to define the order that these inherited templates are displayed.

The templates seem to be sticking to the original order they were added in no matter what. We've tried using the sortorder on the actual base templates themselves, but that doesnt appear to work. Likewise with just reordering the templates in the __Base template field picker.

Any ideas?

回答1:

That is a great approach for templating. To reorder the fields/fieldsets set the sortorder of the Template Fields and Template Sections themselves inside of the inherited templates.



回答2:

I have found that sorting template sections and fields often works best when using negative numbers. Strange but true.



回答3:

I have the same problem with sorting in template inheritance. I have been using a combination of negative and positive numbers, fixed this. Retro fitting does seem a pain and quite a lot of work though. Definitely something to think about upfront.



回答4:

My experience is that fields are added based on the Sort Order of the section, and if two sections have the same value, then the fields are added from the child template first.

Suppose you have a template My New Template that inherits from the Sample Item, with a field in the Data section called My New Field. Even if My New Field has a sort order of 300, and Title and Text are 100 and 200, My New Field will come first if both Data sections are set to 100. To make it come after Title and Text, set the section Sort Order to a higher value, like 150.