Friday, August 18, 2006

5.3: Enabling Edit chunk in Content Editor

You may not see the Edit chunk/button while being logged in as a newly created user. Complete these steps to make it visible: 1. Switch to the core database; 2. Open the Security Editor; 3. Locate this item /sitecore/system/ribbons/chunks/workflow edit/edit; 4. Toggle the inherit checkbox as shown below:

Speeding up File Explorer

On installations with a huge amount of media in the upload folder, you may experience serious delay when opening the File Explorer. If you feel that the upload folder’s existence doesn’t make much sense in File Explorer, you can make this folder invisible; this should speed up the performance. Here are the steps: 1. Locate the File Explorer’s form under \sitecore\shell\Applications\Files\File explorer\ and copy it to \sitecore\shell\Override. 2. In the newly copied file make the following changes: <DataContext ID="FileExplorerDataContext" DataContext="FilteredFileExplorerDataContext" DefaultItem="/" ShowRoot="true" Filter="Not(@@name='upload')"/> <DataContext ID="FilteredFileExplorerDataContext" DataContext="FileExplorerDataContext" DefaultItem="/" Filter="Not(@@name='upload')"/> As can be seen, I assigned a special folder name filter for the DataContext objects. Now the contents of the upload folder should not be loaded to File Explorer.

Sitecore taskbar at the top?

For some inexplicable reason I thought that it is not possible :-) My doubts were destroyed by Jacob. Just move the <startbar> tag above the <border> tag in the /sitecore/shell/Applications/shell.xml file <GridPanel Class="scFill scFixed"> <Startbar GridPanel.Class="scStartbar"/> <Border ID="Desktop" GridPanel.Class="scFill" ContextMenu="ShowContextMenu"> <Border ID="Links" DblClick="Launch"/> </Border> </GridPanel> Result: It turned out that nothing is impossible in Sitecore.

Tuesday, August 08, 2006

Sending data to event handler

You can pass any string/list of strings to your event handler by completing these two steps: 1. Web.config definition: <handler type="Custom.TestEvent, PublishEvents" method="OnPublishBegin"> <mystring>teststring</mystring> </handler> 2. In the code you should define a field named mystring and a property with get and set accessors: private string mystring; public string MyString { set { this.mystring = value; } get { return this.mystring; } }

Accessing the App_Code folder

Since all the classes under the App_Code folder are compiled to an assembly with random name placed under the Temporary ASP.NET Files folder, you are not able to use these classes from an assembly compiled to the bin folder. Let’s assume that we need to create a workflow action class that will communicate with the classes from the App_Code folder. The solution here is to create a workflow action code that will iterate through all the assemblies loaded to the current application domain and find the instance of the necessary class from the App_Code folder and call the Process method. public class CustomAction { static Hashtable table = new Hashtable(); static Type LookupType(string name) { Type result = null; lock (table) { result = table[name] as Type; } if (result == null) { foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { result = assembly.GetType(name); if (result != null) { lock (table) { table[name] = result; } break; } } } return result; } public void Process(WorkflowPipelineArgs args) { ProcessorItem processor = args.ProcessorItem; object instance = ReflectionUtil.CreateObject(LookupType(processor.InnerItem.Fields["dynamictype"].Value), new object[0]); ReflectionUtil.CallMethod(instance, "Process", new object[] { args }); } } As can be seen from the code above, the name of the type that we search for is retrieved from the Action item (dynamictype field): The Type string field contains the reference to the action class compiled to the bin folder. In order to add the DynamicType field to the Action template, you should create a new template e.g. named Dynamic Type by inheriting from the existing Action template and add this new field. You may also want to create a master from this template.
Update: Thanks to Ole, starting with 5.3 BETA 060825 we have made reflection work with App_Code. Therefore, custom processors in App_Code simply work out of the box. In the processor definition, simply leave out the assembly part of the type string: