Tuesday, May 12, 2009

Updated: Standalone apps under Sitecore web root

As this article suggests, it is possible though not officially recommended. Here is an update for what you need to do in Sitecore 6.x to make it happen.

***Updated. (Thanks to the commenters):

The easiest way to do it, especially if you don’t want to inherit anything from the parent Sitecore configuration down to your asp.net app is to use the <location /> config element with inheritInChildApplications="false". With this element you can wrap most config sections like <system.web />, <system.webserver />, etc:


It is worth mentioning that not all configuration sections can be wrapped into the <location /> element.


- Open the web.config of your standalone web app.
- Locate <httpHandlers>section under <system.web> and remove Sitecore specific http handlers:

   <remove verb="*" path="sitecore_media.ashx"/>
   <remove verb="*" path="sitecore_xaml.ashx"/>
   <remove verb="*" path="sitecore_icon.ashx"/>

- Do the same thing for httpModules section:

   <remove name="SitecoreHttpModule" />
   <remove name="SitecoreUploadWatcher" />
   <remove name="SitecoreXslWatcher" />
   <remove name="SitecoreLayoutWatcher" />
   <remove name="SitecoreConfigWatcher" />

- If you are running on IIS7 in integrated mode, you will need to the same thing for the <system.webServer> section:

<modules runAllManagedModulesForAllRequests="true">
   <remove name="SitecoreHttpModule" />
   <remove name="SitecoreUploadWatcher" />
   <remove name="SitecoreXslWatcher" />
   <remove name="SitecoreLayoutWatcher" />
   <remove name="SitecoreConfigWatcher" />
   <remove name="Sitecore.MediaRequestHandler" />
   <remove name="Sitecore.XamlPageRequestHandler" />
   <remove name="Sitecore.IconRequestHandler" />
- Your standalone app will most likely use its own membership provider(s), so you will need to disable Sitecore membership provider:
<membership defaultProvider="AspNetSqlMembershipProvider">
      <remove name="sitecore" />

- If neither role nor profile providers are used, disable them or if you do use them, add the remove statement the same way as it it shown above for the membership provider.

<profile enabled="false">
<roleManager enabled="false">

This way you can easily have an MVC app running in a virtual application (separate pool) of your Sitecore website.

Friday, May 08, 2009

Altering the behavior of the tree view control

You may have noticed this too. When you create a template, the Base Template dropdown may be tricky to operate with. If you are trying to find a template in the subfolders to inherit from and miss the expansion plus, the tree will collapse and you will have to start over. This has been bugging me for a while so I asked the tech support if there is an easy way to fix this and not have the tree to collapse.
Luckily, there is an easy fix, but you will have to mess with the Sitecore.js file located under /sitecore/shell/controls.

What you need to do is to add a global variable in Sitecore.js:

var iAmTree = null;

Then straight after line 563 within scSitecore.prototype.postEvent = function(tag, evt, parameters) add the following:

iAmTree = false;                                                                                      
if (ctl.className.toString() == "scTreeItem") iAmTree = true;  

And finally within scRequest.prototype.resume = function() alter this IF statement:

if (this.closePopups && typeof(scForm) != "undefined") {

to this:

if (this.closePopups && typeof(scForm) != "undefined" && iAmTree != true) {

This will also affect the Droptree field’s behavior and possibly more areas.

And you may have guessed – create a backup of Sitecore.js file and use the solution on your own risk ;-)

Special thanks goes to Ruslan for providing the fix.