Posts

Adding custom properties to Social Connected users profile

Social Connected module gives the ability for website users to register through their social networks, like Facebook, Twitter, Linkedin and Google+, the module does a good job of mapping users data from these networks and add them to user profile in sitecore. Recently, we needed to add our own custom properties into users registered through Social networks, i was able to do this by using [social:connector:user:created] event. The following code grabs the user object from event parameters, and update the profile with our own custom property: namespace Sitecore.SharedSource.Events.Social {     public class UserCreated     {         protected void UpdateUserProfile(object sender,  EventArgs args)         {             var user = Sitecore.Events.Event.ExtractParameter(args, 0) as Sitecore.Security.Accounts.User;   ...

Convert item to bucket item programmatically

Item buckets lets you store millions of items in a repository without having a direct parent-child relationship, which solves the problem of having large number of items in content tree. Any item in sitecore can be converted into item bucket from Content Editor, by going to ' Configure ' tab then clicking ' Bucket ' to convert the item into item bucket. I was able to write some helper methods to conver item to Item bucket programmatically , in case you were importing large number of data and you wanted to covert items into buckets on the fly. public static void ConvertToBucketItem(Item item)     {         using (new SecurityDisabler())         {               Sitecore.Buckets.Managers.BucketManager.CreateBucket(item);             using (new Sitecore.Data.Items.EditContext(it...

Integrating Lucene.Net.Contrib.Spatial with Sitecore Search API (Geo-Spatial Search)

Image
Note : Newer release is published on github  that support sitecore 8.1 & 8.2 and fixes the issue with location results being cached, Go to this post to read about the details of the new release I have created an Extension to Sitecore.ContentSearch API which uses Lucene.Net.Contrib.Spatial library to generate spatial queries. Currently, i added a method " WithinRadius() " to retrieve locations within specific radius (In miles) of center point , the results will be sorted based the distance from the center point. This extension assumes that you have Latitude and Longitude stored as fields in your location items. Installation :  You can either get the source from github or install nuget package.     Marketplace : Go to Sitecore Marketplace and download "Lucene Spatial Search Support" package. Install the package using Sitecore Installer wizard Configurations : Go to ' Sitecore.ContentSearch.Spatial.config ' file in your include fol...

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 template If your site runs on Sitecore MVC, Do the following Create a class call...

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, se t Authentication.SaveRawUrl to 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 = Htt...

Apply changes to cloned items immedialtley using Sitecore Workflow

Image
Intoduction Sitecore Cloning items is new feature in 6.4 version, it give the ability to reuse same item content in different places in your site, clone item is an actual item that points to another item called origin, and hold the same field's data as the origin. For more information on clone items, read this document . The Problem Creating new version of origin item, will push a UI notification  for user to accept the new change on every cloned item, this could be time wasting for some people if they want these changes to be reflected immediately. The Solution Using Sitecore workflow actions, we can enforce origin item new version changes to be reflected on all clone items. Note : You should notice in code snippets below that states IDs and Commands ID are hard coded here to use Sitecore Sample Workflow, if you plan to use your own workflow, you will need to change these IDs as fit.   1- Origin item template should use Sitecore sample workflow. 2-...