Tuesday, August 25, 2009

Item Serialization and the Developer Tab

Question: “Are Sitecore items serializable?”

Yes, for example, items are serialized when they are added to packages.

Also, there are serialization options on the Developer Tab.

The resulting files can be found under %siteroot%/data/serialization.

A blogpost from Alex DeGroot explains what the various commands do and more about serialization.

http://sitecore.alexiasoft.nl/2008/08/04/sitecore-6-serializating-items-and-whole-database-part-2/






The Developer Tab is not displayed by default. To display it, right-click in the blank area next to the Tabs and the Ribbon and select “Developer”. You will see the serialization commands.

Another useful set of commands are ID and Path in the Show group. These commands will give you the Sitecore GUID or Content Tree path for the currently selected item. When you select one of the commands a dialog box will appear that prompts you to copy the information to the Windows Clipboard.

Monday, August 24, 2009

Language in the URL, Resetting Fields, Text Length

Here are a few quick answers to some commonly asked questions:

Question: “Why will the language designation (such as “en”) sometimes be included in the URL and sometimes not? How can this be controlled so that never displays?”

Answer from John West: “When <languageEmbedding> is set to “asNeeded” (in the LinkManager section of Web.config), Sitecore includes the language in the URL if it cannot determine the context site from the incoming HTTP request, if that HTTP request does not include a cookie that specifies a language, or if the language of the linked item differs from the context language. You should, set the <languageEmbedding> attribute to “always” or “never” to get the behavior you require.”




Chapter 5 of the Content API Cookbook describes dynamic link management:
http://sdn5.sitecore.net/Reference/Sitecore% 206/Content%20API%20Cookbook.aspx




Question: “How can it be configured that an empty field is the same as NULL for resetting to Template Standard Values (TSV)?”


Answer from John West: “I think it could be the “reset blank” field in the data template field definition, or it may require custom logic such as an event handler.”


The “Reset Blank” field does the trick. If you delete the contents of a field in Content Editor, the blank field will be replaced with the default from Template Standard Values on the next Save.








Question: Is there a maximum length for a Single-Line Text field?

There doesn’t seem to be a set limit. I tested this by adding more than 15,000 characters to a single line text field and didn’t receive an error. (Formatting this would be a different problem, however.)

Thursday, August 20, 2009

Using ASP.NET AJAX Update Panel with Sitecore

A question came up during class last week about using the ASP.NET AJAX controls, particularly the UpdatePanel to improve the responsiveness of a Web page when doing the Poll Sublayout. This is a perfect example of when you would want a partial page update, rather than a full postback, when moving through a series of poll questions.

I did a little testing after class and found, as some of you did previously, that the UpdatePanel control did not seem to be working as expected in the Sitecore environment. I mentioned this to my esteemed colleague Seth Luersen and he knew immediately where to find the solution.

He directed me to this post on the SDN Forums:
http://sdn.sitecore.net/forum/ShowPost.aspx?PostID=5563

Although this post is a couple of years old it does address the issue.

I checked for the correct <httphandlers> in web.config:

<httphandlers>

<add path="ScriptResource.axd" verb="GET">

type="System.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httphandlers>



That seems to be in place by default in Sitecore 6. However, a later reply mentioned the IgnoreUrlPrefixes setting.

<setting name="IgnoreUrlPrefixes
value="/trace.axd/sitecore/shell/Editor/sitecore/admin/upgrade/UnhandledException.aspx/
webresource.axd/ScriptResource.axd"/>


Adding ScriptResource.axd to this setting seems to be the key enabling the expected AJAX partial page update behavior.

So, thanks again to Seth for pointing this out. Let me know if this works out for you. It’s great to see how easy it is to add AJAX functionality to Sitecore.