Tuesday, January 27, 2009

Comprehensive Configuration Guide

We have published the configuration guide for Sitecore 6. The document was in the draft state for a while and now it is officially released after thorough review. It covers multiple configuration options as Sitecore is pretty flexible in that perspective.

The set of databases for the content delivery instance can be reduced to only one "web" and the size of this instance in default configuration can be decreased to 20 MB  (!!!) by removing the whole "/sitecore" folder.

There are ready-to-go web.configs and backups of the databases for a quick configuration effort.

Saturday, January 17, 2009

Friday Gotcha: Sitecore.Data.Items.Item.Fields

For the sake of performance, Sitecore will not give you all fields in the FieldCollection in the following code, only fields with explicit values on item level, including empty string:

foreach(Sitecore.Data.Fields.Field field in Sitecore.Context.Item.Fields)
  // here you will see only fields with values (even empty string) set on item level
  // fields with null in them or standard values will not be here.

However, you will be able to access fields with either Sitecore.Context.Item.Fields["title"] or with a PageEditor enabled Web Control such as sc:text: <sc:text field="title" runat="server" />

In order to have all the fields in the FieldCollection and iterate through them, make sure your code will include Sitecore.Data.Items.Item.Fields.ReadAll() call before your foreach:

foreach(Sitecore.Data.Fields.Field field in Sitecore.Context.Item.Fields)
  // do your thing here

FAQ about this.

Wednesday, January 14, 2009

One of the things to remember before you go live

As I mentioned in one of my previous posts, it is always a good idea and common sense to block at least a week in project's timeline for load testing and performance optimization of your web site before the launch.

The performance optimization is a good topic for a separate blog and will not fit into one post BUT one of the things can be done pretty easily and give drastic performance improvements (2x and more times) for the content delivery side, also take the load of your SQL box. I am talking about database-level caching, particularly Item and Data caches.

First thing to check is the current max cache sizes of Item and Data caches on the cache statistics page, and it makes a lot of sense to perform this check while your solution is under the load testing: http://localhost/sitecore/admin/cache.aspx

If the values of "Size" column for web[data] and web[items] are approaching the "MaxSize" value, consider adjusting the values in web.config. There are no actual rules here 'cause the recommended values depend on your solution (content volume mostly). So by playing with the values, find the one that fits your needs. What will happen if your caches are maxed out? Nothing too exciting, actually. The next item information will trap into the cache but some lonely item will be evicted without two week notice.

You can find the description of cache settings here, but in nutshell, there are multiple locations where you can specify cache sizes:
1. /databases/database
2. /cacheSizes/databases
3. /settings/Caching.Default<cache_name>Size
4. value assigned in the assembly as a last try.

This is the order of processing. If any value greater than 0 is defined in a higher level, this value will be returned.

As for #3, it is important to note that some caches do not have the default cache values defined in the <settiings> section. This includes ChildCache, ParentCache and ItemCache. So if the search of the cache size falls down to #3, the value specified in code will be assigned.

As a part of the cache value assignment process, check this known issue for 5.3.x version, you may need to adjust the names of the caches. In Sitecore 6 it is not an issue.

I also want to stress that same rules are applied to other database-level and website-level caching types.

Tuesday, January 13, 2009

Gotcha: cache settings on a rendering, sublayout or web control

A very minor change was made in version 6 as for the caching settings on the presentation controls, easy to get caught. The data template section that hosts the caching checkboxes is considered as "Standard Field" section so it is not visible unless the Standard Fields are enabled.

So if you are trying to adjust global caching settings for a rendering, sublayout or web control you will need to locate it in the appropriate branch underneath /sitecore/layout and don't forget to toggle "Standard Fields" to have the "Caching" section with the chekboxes show up:

In addition to Sitecore debugger where you can identify whether your renderings are actually retrieved from cache, there is a very convenient tool to check the cache settings is /sitecore/admin/stats.aspx
It filters by website, counts the instances of the renderings, shows you the number of cached instances, etc.

Update: it is actually considered as a bug and will be addressed in upcoming major update.

Friday, January 09, 2009

How to control the sort of languages in the selector

A great article was just published by Igor regarding the way to control the language sorting. By default, the languages that show up in that list are not sorted by name, but by the date they were created.
In the multilingual solutions with more than 10 languages this may cause some confusion from the editors perspective that have access to multiple languages. If there are not security settings specified on the language level, this may be a bit of an inconvenience.
Using this solution, you can control the language sort order by either name as it is shown in the example or by other parameters, such as number of versions of example.

Kudos goes to Igor for the solution!

Thursday, January 08, 2009

jQuery conflicts with PageEditor

There is such problem, indeed. It is caused by the conflict with Prototype.js that most of Page Editor, including designer and debugger uses. It can be simply worked around by overriding the $-function by calling "jQuery.noConflict()".
<script type="text/javascript" src="/js/jquery-1.2.6.js"></script>
<script type="text/javascript">
var $j = jQuery.noConflict();
      $j(document).ready(function() {
More about that on the jQuery website.