Saturday, 8 September 2018

Sitecore 9 Dynamic Placeholders And Why we need them

As many of us have faced the issue of repeating content when trying to use same placeholder name, Sitecore 9 has filled this gap by introducing support for Dynamic Placeholders in Out of the Box installation.

Problem Statement and when to use Dynamic Placeholders:
In the below example I will reproduce an issue when I use a standard Sitecore placeholder:
That is:

I have created here:

  1. Layout.cshtml  - A layout file with 3 placeholders: Header, Main, Footer
  2. Sublayouts 
      • Section - A sublayout view with following code:
      • 1 Column - A sublayout view with following code.
  3. A Hero image component - This a sample component for example. We can use any other component. It contains 2 fields: Title, Image.
Important Note: None of the above placeholders will allow us to add a rendering in it if we don’t create a placeholder setting item for them under: /sitecore/layout/Placeholder Settings.

Saturday, 21 July 2018

Creating and Installing Sitecore packages programmatically

We can create and save a Sitecore packages on disk using code.
Following method takes List of items as an input parameter and can be used to package the supplied items:

Note: The above code will create the package for you in the C drive/ Data folder.

Wednesday, 13 June 2018

Moving Archived items from one Sitecore instance to another

In continuation to my previous posts I will be sharing some steps in which we can package up the Archived items and move them from one Sitecore instance to another.
This can be a requirement for many migration projects.

Note: We can only create a package for items which are in content tree(i.e non Archived/deleted).

Following are the steps we can follow to move archived items:
1. Get list of all archived items from source instance master DB. (programmatically)
2. Restore the list of archived items from step 1 to the source instance. (programmatically)
3. Create Sitecore items package of the restored items. (programmatically)
4. Archive the restored items again on source instance DB. (programmatically)
5. Grab the sitecore package created in step 3 above and install it on the destination instance.
6. Read items from the package and archive them.

Saturday, 2 June 2018

How to Archive and Restore Sitecore Items programmatically

Content Author can archive items any time from Sitecore client by using Archive button in the Review tab.

And later can restore the archived items form the Archive application.

However, we can have a situation where we need to archive or restore items based on some action.
Following is the code which can be used to archive items programmatically:

Saturday, 12 May 2018

Copy bulk Sitecore Items between instances

Today I am going to talk about a very common issue which we face when working with more than one environments/instances of Sitecore.

Moving bulk content and specially media items is a tedious task for which I have written this blog post.
We have some tools that can do the job for us but most of them need paid license to use.
Another way to achieve this is by using a very powerful Sitecore scripting tool called as Sitecore powershell extensions(SPE).

Firstly, we will talk about the tools that can help moving bulk content items:

  1. TDS/Unicorn: These are 2 similar tools, which can be used to serialize items and then sync across various instances of Sitecore. TDS is having more features but needs paid license to use. Unicorn is free and can be used to setup for serializing the items.
  2.  Razl : This is a great tool created by Hedgehoge, which can be used to compare and move items from one instance to other. Using this we can compare 2 databases side by side and simply move items from left to right and vica-versa.

This tool can be very useful as it gives us the clear picture of all items and there presence in each instance.

Wednesday, 3 January 2018

Create custom Sitecore SXA renderings and components

The blog post example has been created on following versions:
  •          Using Sitecore 8.2 (rev 170407) update 3
  •         Sitecore Experience Accelerator 1.3 rev. 170519 for
     Below we will see the steps to create SXA compatible custom rendering.
       SXA compatibility should have the following features:
  •          Available in toolbox
  •          Would support drag and drop
  •          Will help content authors with help text and areas where they can insert
  •          Can have multiple variants
  •          Will support SXA OOB styling

Here, I am taking an example of a custom carousel where we have the following requirements:
Carousel will have following global settings:
  •          Can have a background colour

Each carousel slide can have:
  •          Title
  •          Description
  •          Image
  •           Link