Thursday, January 23, 2014

Running Sitecore in LiveMode

LiveMode means running the front-end site using the master database (instead of web database).
To do this, in the relevant site definition, change the "database" property to "master"

Also, you need to set the "enableWorkflow" setting to "true" to avoide displaying items that does not reached the final workflow.

i.e.
<configuration>
  <sitecore>
    <sites>
      <site name="[YOUR_FRONT_WEBSITE_NAME]" ... database="master" ... enableWorkflow="true" ... />
    </sites>
  </sitecore>
</configuration>

PlaceholdersEditableWithoutSettings setting from sitecore 6.5

From sitecore 6.5 (CMS 6.5.0 and DMS 2.0.0 rev. 110602 ) onwards,
if you go to the page editor and try to edit, it won't display any add button/placeholder if placeholder settings were not configured in layout details of the item (i.e. item -> presentation -> details)


<!--  WEB EDIT PLACEHOLDERS EDITABLE WITHOUT SETTINGS
      Indicates whether placeholders should be editable in the Page Editor if placeholder settings are not specified.
      Default value: false
-->
<setting name="WebEdit.PlaceholdersEditableWithoutSettings" value="false" />


if needs to use dynamic placeholders or need to edit a placeholder without setting placeholder settings prior, then set this setting to "true".

Friday, January 17, 2014

Ways to Find Versions in Sitecore

To find the current sitecore version

Method 1 :
Login to sitecore desktop then go to the following path
Sitecore Start Button -> All Applications -> System -> About Sitecore

Method 2 :
At the start of the sitecore log files, sitecore writes the version details of its main dlls.
i.e. Sitecore.Kernel.dll and Sitecore.Client.dll

Method 3 :
Following way can be used to find the sitecore dll version.
Wright Click on Sitecore.Kernel.dll in the /bin directory -> Properties -> Details

Note: This method may not actually reflect the current sitecore version correctly, if the dll's are changed/replaced by different sitecore version.



To find the currently installed Module version in sitecore 
(i.e. WFFM, ECM, etc)

Wright click on the relevant .dll file in the /bin directory -> Properties -> Details
   Ex: Sitecore.EmailCampaign.dll




Saturday, January 4, 2014

Launch Sitecore - Sitecore teach how to build a site using sitecore

Launch Sitecore (http://www.launchsitecore.net) is a place where you can find/learn fundamentals of building a site, best practices as well as DMS functionality.

This site is available as a sitecore package. Anyone interested can download the launchsitecore package from the site and install it in a local sitecore instance and learn/explore how sitecore has done things.

Friday, January 3, 2014

StripLanguage processor in the pipeline causes error in multi-site setup

In 6.6 Update-6, the StripLanguage processor in the <preprocessRequest> pipeline was changed so that it always parsed languages from the URL, even when languageEmbedding was set to "never" in <linkManager> setting.

Sitecore implementation with multisite/multilingual setup start to cause some issues with this change if the implementation is using virtualPath and physicalPath properties in <site> definitions to define urls.

The solution for the above issue was to remove the "StripLanguage" processor from the <preprocessRequest> pipeline.

With the sitecore 6.6.0 rev 131211 (update-7) version release, sitecore has introduced a new setting in web.config to overcome the above mentioned issue.
<!--  LANGUAGES ALWAYS STRIP LANGUAGE
      This setting specifies if the StripLanguage processor in the <preprocessRequest> pipeline will parse and remove languages from
      the URL, even when the languageEmbedding attribute of the linkProvider is set to "never". You should only change this setting
      to "false" if the default behavior causes problems in your solution.
      Default value: true
-->
<setting name="Languages.AlwaysStripLanguage" value="true" /> 
"In 6.6 Update-6, the StripLanguage processor in the <preprocessRequest> pipeline was changed so that it always parsed languages from the URL, even when languageEmbedding was set to "never". This caused problems for some customers, so a new web.config setting named Languages.AlwaysStripLanguage has been introduced. You can set this setting to "false" to return to the earlier behavior. (390434)" Quote from sitecore

If the sitecore solution is using multisite/multilingual site setup and languageEmbedding is set to "never" in <linkManager> setting, then make the above setting (Languages.AlwaysStripLanguage) to "false".

Thursday, January 2, 2014

Implementing Bundling and Minification with Sitecore Web Forms site

Bundling and Minification is introduced in .NET 4.5 with System.Web.Optimization namespace.

These new functionality can be implemented with .NET 4.0 as well.

Following are the steps to implement Bundling and Minification functionality with Sitecore Web Forms.

1. Dependencies
  • System.Web.Optimization.dll
  • WebGrease.dll
2. Defining Bundles

Method 1 - using RegisterBundles class method

using System.Web.Optimization;

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/Styles/Site.css"));
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
     }
}
 
Method 2 - using config file  (bundle.config) - Only static style bundles

<?xml version="1.0" encoding="utf-8" ?>
<bundles version="1.0">
  <styleBundle path="~/bundles/css">
    <include path="~/Styles/Site.css" />
  </styleBundle>
</bundles>


3. Register Bundles
Bundle registration can be done in two ways.
  • In the Application_Start method in Global.asax file
         RegisterBundles(BundleTable.Bundles);
  • As a custom pipeline processor in /Configuration/Sitecore/Pipelines/Initialization by editing web.config file
using System.Web.Optimization;
using Sitecore; 
using Sitecore.Pipelines;
 
namespace MyWebProject
{ 
  public class BundleConfig
  {
    [UsedImplicitly]
    public virtual void Process(PipelineArgs args)
    {
        RegisterBundles(BundleTable.Bundles);
    }
    public void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/Styles/Site.css"));
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
     }
  }
} 
Add follwing pipeline to /Configuration/Sitecore/Pipelines/Initialization as the final processor

<processor type="MyWebProject.BundleConfig, MyWebProject" />

4. Adding Namespace
Under the "/configuration/system.web/pages/namespaces" in web.config, add following namespace

<add namespace="System.Web.Optimization" />
 
5. Adding Bundles to View/Layout
In the main layout page in the head section, add style and script bundle virtual path references

<%: Scripts.Render("~/bundles/css") %> 
<%: Styles.Render("~/bundles/jquery") %> 

6. Allowing bundle virtual path urls to access files
"IgnoreUrlPrefixes" config setting in web.config file

<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/bundles" />

7. Enable/Disable Minification
In the web.config file,  fine the "<compilation" tag and set "debug" property to "false" to enable bundling and minification.

Note: if you want to debug scripts and styles, setting debug="true" will ease the debugging process, since when debug="true", bundling and minification will not take place.

<compilation debug="false" targetFramework="4.0" />

Important Notes:
Best practice is to use include config file to do the config changes rather than doing it directly on web.config file


Update 1:
* Dependencies can be installed by importing the Microsoft.AspNet.Web.Optimization package.
* If the version is greater than or equal to 1.1 (1.1>=), then Styles.RenderFormat method is also available. This support the formating of the input html tag.
     Ex:  <link ref="stylesheet" type="text/css" media="screen" ..>

Limitations :
System.Web.Optimization mechanism does not convert relative image reference paths inside the .css file. Workaround will be to use Absolute path in image references inside .css files.


References
http://blogs.msdn.com/b/rickandy/archive/2012/08/14/adding-bundling-and-minification-to-web-forms.aspx
http://blog.vicreative.nl/2013/09/automatic-bundling-and-minification-in-net/
http://jockstothecore.com/bundling-with-sitecore-mvc/