Posts

Sitecore Spatial/Geo Location Search Module

Image
Previously i have released Sitecore.ContentSearch.Spatial module that support applying Geo-location based search using Sitecore ContentSearch API, That release had some issues with results getting cached and not updating when you publish the location items or make changes to them, Also it required that you use different [documentBuilderType] than Sitecore default.

In the new release you only to update your index to use (Sitecore.ContentSearch.Spatial.Provider.Lucene.LuceneIndexWithSpatial) class, and to add two computed fields configurations to your Index configurations, and that's it!

To install this module,

Download or clone this repository on github to your machine, As of now, i'm using  references for Sitecore 8.2 -Update3 from Sitecore Nuget feed, You can update the references to match your Sitecore versions using Nuget Manager.Build the solution and copy the following dlls from the bin folder to your project:Sitecore.ContentSearch.Spatial.dllSpatial4n.Core.dllLucene.Net.C…

Attaching a file on WFFM Send email action

On Sitecore 8.1 i recently faced this issue, We have a CM/CD setup and we are using WFFM for our forms, One of the forms has a file upload field where we store the file in media library, and We have "Send Email" action where we also add the uploaded file link, However, what we are seeing in the email sent that Sitecore is generating the File URL with CD domain, in this format:

https://{CD Domain}/sitecore/shell/themes/standard/-/media/{guid}.ashx?db=master

We are disabling sitecore shell access on CD, so we can't really access this URL, So i reached out to Sitecore support team for help, they said this behavior is registered as a bug (ref 77357) and they gave the following workaround as a solution which is basically to attach the file into the email itself :

Navigate to /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions/Send Email Message item. In Parameters field add the following: true.Save and publish changes.
uploaded file will be added into e…

Update item name using Sitecore Item Web API

Recently i have been using Sitecore Item Web API frequently to add/update/retrieve content from sitecore, Its easy to setup and use, and can save you time and effort when you integrate sitecore with other plateforms/systems
Developers use the Sitecore Item Web API to manipulate the content items in Sitecore through HTTP requests. The API gives access to content through items paths, IDs, and Sitecore queries. This service produces output in JSON format and is both highly customizable and optimized to support a minimum number of requests.
Sitecore Item Web API 1.0.0 Developer's Guide

 I was asked a question recently on how to change Sitecore Item through the Item web API, and i thought that should simple and out of the box, right?

Well, i was wrong, i could not find that its possible to update item name while going through Sitecore documentation:

Updating Existing Items The HTTP PUT method is used to update existing items. This affects all items in the resolved scope. To update the ite…

Caching Rendering HTML when conditional rules are applied

Image
Applying Sitecore caching is an essential task when you build your site, It help improve your site general performance and decrease response time significantly , Output HTML cache is one of the different types of cache that Sitecore offers, I almost apply it everywhere on site rendering components.

However, If you are applying Conditional rendering on a component (Personalization) and you are setting different datasources based on some conditions, Applying Caching on that Component with "Vary by Data" option checked will not work as expected, At first i thought that Sitecore will resolve Component datasource by applying the Conditional rules before adding that to the "Cache Key", That was not the case :( .

It turned out that Sitecore uses the default datasource applied on the component to generate the Cache Key, So you will always see the "Default" version of the component on the page, And all of Conditional rules will be ignored.

I'm using MVC for th…

Solr with Sitecore Checklist

Image
We have been using Solr with Sitecore for our latest Sitecore implementations as it offers better index synchronization across all CD/CM servers since its a standalone web app with HTTP access, which means that all CD/CM servers will have up-to-date indexed content, unlike lucene where each Sitecore server is responsible of synchronizing its lucene index, which sometimes breaks and causes content to be out-dated.

This blog is not about how to configure Solr with Sitecore, there are many blogs talking on this subject, This blog is about some considerations and best practices that you need to take into account when you setup Solr with Sitecore.


First, Disable Indexing on CD's

With Solr/Sitecore setup, you only need to enable indexing on CM, and disable it on CD servers, By default after any publish operation, Sitecore will store (item changed/added) event into Event Queue table, and each Sitecore instance will pick that and trigger index job for that item, With Solr we only need CM …

Set Workflow using Item Buckets Search Operations

Image
Recently one of our clients asked to set the workflow on large number of items that were created without workflow, so i was thinking of writing a script on powershell to do that, but then i thought why not extend Item buckets Search operation and add "Set Workflow" option there!

Basically, You will need to write a command that sets the workflow for all items in search results, and register that command.

1- The Code:


2- The Configurations:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">   <sitecore>     <commands>       <command name="bucket:setworkflow" type="Sitecore.SharedSource.Buckets.SearchOperations.SetWorkflow, Sitecore.SharedSource.Buckets.SearchOperations"/>     </commands>   </sitecore> </configuration>
3- Adding Command item in Sitecore:

 Open Content Editor and go to "/sitecore/system/Settings/Buckets/Settings/Search Operations/Fields"Create new item of Template "/s…

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;             if(user!=null)             {                 user.Profile.SetCustomProperty("CustomPropertyName", "CustomPropertyValue");                          …