Posts

Showing posts from September, 2014

Disable caching for a rendering on some pages

Everyone loves Sitecore caching capabilities, especially HTML Caching, where you can cache the output HTML of any  rendering.

When you want to cache any rendering, you have two options:
On rendering definition item, Set 'Cacheable' checkbox On item presentation details, Select your rendering and set 'Cacheable' checkbox. The problem with the first approach is that once you set the 'Cacheable' option on definition item, any page that uses this rendering will always cache it, and you can't cancel the caching for that rendering on some pages that you dont want it to be cached there.

I found a solution for this, where you can disable any caching setting for any rendering, :
 Create a new rendering parameters template which includes a checkbox field called "Cancel Cache Settings'Go to your rendering definition item, and set the parameter template to the new templateIf your site runs on Sitecore MVC, Do the followingCreate a class called 'SetCacheabil…

Redirect to original preview URL after login through sitecore

I saw a question recently on Stackoverflow asking about when you send a preview link to the next person in workflow for approval, assuming that person is not logged in into sitecore yet, the preview link will redirect to sitecore login page, and after logining in, sitecore will forget about the orginal preview URL and go directly into sitecore desktop/Content editor.

So, after looking into how sitecore login pipeline works, i found this solution:

In your web.config, set Authentication.SaveRawUrlto true, this will make the original requested URL passed to login page in a query string 'url' Create class called "LoginRedirect":  using System.Web; using Sitecore.Pipelines.LoggedIn; using Sitecore.Web; namespace Sitecore.SharedResources.Pipelines.Login { public class LoginRedirect : LoggedInProcessor { public override void Process(LoggedInArgs args) { if (Sitecore.Context.GetSiteName() != "login") { return; } string url = HttpUtility.UrlDe…