Posts

Building Sitecore Content Search Queryable using Rules engine

Image
Recently i have built a custom search module which uses Sitecore Content Search API that would let you define the search criteria directly from content editor, where you would be able to select which index, start locations, Templates that you want the results to filter on from the content tree i also wanted to add fields filter, like filter on checkbox, date, Single-line Text fields etc. I had an idea to build this Fields filter using Sitecore Rule Engine since it seemed like a good fit here! Imagine you would be able to build a filter like: Where [Field Name] is equal [String Value] That would be nice, right? So i started digging into rules conditions and see how can i make this possible, And came to my surprise that Sitecore have built a predefined set of conditions to do just the job! Using this Query builder rule [ /sitecore/system/Settings/Rules/Search Query Builder ] you will be able to see the set of conditions for Search query where you can build your filter,

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.dll Spatial4n.

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 w

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.

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 usin

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 w

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 it