Does a Sitecore item derive from a template

This is my fifth post in a series about creating Sitecore .NET extension methods on a Sitecore item. I love extension methods and have been using them to wrap common operations on Sitecore items since they were introduced in .NET 3. The series of posts will also contain an architectural description on how to implement and maintain your extension methods so these are re-usable in all of your Sitecore solution s. ...

November 7, 2013 · 3 min · alc

Sitecore Analytics: Display content by relevance using profile cards

For this post to make sense I will need to create a user story. I will not try to create a standard scenario instead I will create a scenario that is easy to understand and easily applicable to this post. The problem we want to solve is to present some content to the user that is relevant to the content that the user is looking at in any given time. ...

November 4, 2013 · 3 min · ap

Ensuring roles in Sitecore

Roles are easy to create in Sitecore but sometimes you might want to ensure that some specific roles always exists. Not a very common scenario but nonetheless it happens. Once upon a time we needed to be able to ensure that a long list of specific roles always existed on the production instance otherwise some of our code and an integration to an external system could fail. Inspired by the EnsureAnonymousUsers processor in the initialize pipeline I made the following small module. It is very similar to the code I shown in my previous post on how to disable the admin user. ...

October 30, 2013 · 2 min · alc

Lucene: Indexing DateTime from Sitecore and querying date ranges

The title should be self explanatory. I need to index some sitecore items that represent some entities that are valid to the public between certain dates. The sitecore fields are date time fields looking like this. I needed a solution for indexing these values in a way that i can do range queries on them. I used the UnixTimeStamp for converting the DateTime field in a UnixTimeStamp field. public static string ConvertToUnixTimeStamp(DateTime value) { var date = new DateTime(1970, 1, 1, 0, 0, 0, value.Kind); var unixTimestamp = Convert.ToInt64((value - date).TotalSeconds); return unixTimestamp.ToString(CultureInfo.InvariantCulture); } Decoding UnixTimeStamp to DateTime : ...

October 29, 2013 · 1 min · ap
Sitecore admin

Disable the Sitecore admin user

A basic Sitecore 1-0-1 security check is to see if the admin account still uses the standard password. It is commonly seen that sites go into production with the admin / b still working. A way to ensure this does not occur is simply to disable the admin account when building to release or other public facing configurations. Disable Sitecore admin user We first create a setting for toggling if the admin user should be disabled. ...

October 29, 2013 · 2 min · alc
crunchpng

Crush png in Sitecore

This post describes a module to crush png in Sitecore which can be downloaded from Sitecore MarketPlace and the latest version of the code is also available free on github. Continuing my fight with Google Page Speed. .NET does not offer an approach for compressing png files other than the default compression. This makes it hard to please google page speed automatically since one of their checks is if the images on a site are losslessly compressed. ...

October 26, 2013 · 6 min · alc

Creating a custom pipeline in Sitecore

Pipelines are one of the most essential parts of Sitecore and creating your own custom pipeline in Sitecore makes your code extremely flexible for both you and others. It is extremely easy to create and run a custom pipeline as this post will show. Defining the pipeline A pipeline consist is a set of processor classes which each has a method called Process which takes one argument of PipelineArgs or a derived class. ...

October 25, 2013 · 1 min · alc

Changing a PDF on the fly using Sitecore Media Request

Some time ago I had a fun challenge for a customer. They wanted a legal notice pdf to be appended to all PDF files which was downloaded from specific parts of the media library on the fly. They also wanted to be able to update the legal notice pdf and use a different one for different parts of the media library. The same concept could also be used for adding a watermark to a pdf or maybe removing all above the first three pages for non-authenticated users etc. ...

October 23, 2013 · 3 min · alc

Preview deletes the .aspxauth cookie

I’ve been working a bit on an extremely weird support case the last couple of days. When the editors on a site clicked on preview from either the content editor or the page editor then the page ended up in a redirect loop. Who stole my cookie? Using Fiddler I quickly noticed that the .ASPXAUTH cookie was removed from the session as soon as preview was clicked and what actually happened was the user being redirected infinitely to the login page until the browser crashed (chrome crashes nice, IE just fails miserably). ...

October 23, 2013 · 2 min · alc

Creating a customHandler in Sitecore

Sometimes you would like all requests to a specific path and below to be handled by a specific generic handler. For example in the same manner as the mediaHandler works in Sitecore. Setting up a customHandler in Sitecore Configuring a normal httpHandler in .NET is easy, you simply add entries in the web.config depending on your version of IIS. Under /configuration/system.webServer/handlers ( for IIS 7 and above) <add verb="*" path="examplehandler.ashx" type="[NAMESPACE].ExampleHandler, [ASSEMBLY]" name="ExampleHandler" /> and the same under /configuration/system.web/httpHandlers (for older versions of IIS) ...

October 22, 2013 · 2 min · alc