Sitecore Core Development

Thursday, October 06, 2005

UI design

This blog is very funny if you ever tried to design a good UI with a user. It closely resembles the way that the desktop windows in Sitecore evolved - and pretty much all the other UI in Sitecore.

The ratio between API and UI bugs in our bug tracking system is about 1 API bug to 5 UI bugs and I think that many of the reasons can be found in this blog (or perhaps Ole is just a better programmer than I).

http://miksovsky.blogs.com/flowstate/2005/10/the_fractal_nat.html

Wednesday, October 05, 2005

Modifing the Preview Sidebar

It is possible to add custom content to the Preview sidebar. The sidebar is a portal that contains a number of portlets. The portal is defined in the Core database in /sitecore/content/Applications/Preview.

One way to extent the sidebar is to add new portlets to the portal.

If you just want to add a menu item to the options in the sidebar, add a new menu item to the /sitecore/content/Applications/Preview/Toolbar item. The menu portlet then draws the menu item as part of the standard menu.

The popup menu on the dots cannot be altered. This reason for this, is to keep the menu clean and performant. It is quite an expensive menu to draw, so it should be kept to a minimum.

Showing a modal dialog on load

When a form loads, Sheer UI post-backs are disabled. This means that any calls to methods in the ClientPage.ClientResponse object is ignored.

It is therefore not possible to show a modal dialog using ClientPage.ClientResponse.ShowModalDialog during load.

The following won't work:

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);

if (!Sitecore.Context.ClientPage.IsEvent) {
// won't work
Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog("/mypage.aspx");
}
}

A solution is to use to some JavaScript, that runs when the page has loaded, to trigger an event on the server which will show the dialog.

The FormPage control has an OnLoad property which is very useful for this scenario.

So the XML layout could look like this:

<FormPage onload="'javascript:scForm.postRequest('', '', '', 'OnShowModalDialog')">
...
<FormPage>

The CodeBeside object should contain a method named OnShowModalDialog.

protected void OnShowModalDialog() {
Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog("/mypage.aspx");
}

When the page loads, the OnLoad javascript is triggered, which then sends a request to the server. The server sees this as a Sheer request and the ClientResponse object is enabled which make the ShowModalDialog work.

Monday, October 03, 2005

Disabling the HTML view button

In the HTML editor a user can view the HTML code by clicking Zoom and the HTML button at the bottom of the editor.

This HTML button can be disabled (in version 5.1.0.5) by setting security permissions on the item /sitecore/system/Settings/Html Editor Profiles/<profile>/Buttons/Html View.

If the user does not have read access to this item, the button does not appear.