Sitecore Experience Accelerator – What is new in rendering data source

I recently started looking into the features of Sitecore Experience Accelerator module and in this post I will share my understanding for few new ways of assigning datasource to a rendering that comes with SXA.

Motivation

With the new concept of page/partial design in SXA I noticed following things those motivated me to know more about it and write this blog post.

1. Relative Data Source:
The first thing I noticed is the datasource field value as relative path in the rendering. As you can see in the below image, the selected item is a partial design item named as “Footer” and the control properties window shows the relative datasource for a control with some special starting keyword as “local” and after that a relative item path.

SXA-datasource-1

Figure 1: Page Relative Datasource

Clearly it means there must be some resolvers those will be doing the magic of converting a relative path to full item path.
The questions are which resolver is doing that? And are there any more resolvers?

2. Datasource change is not allowed from page for a rendering that belongs to partial design:
On a page if rendering is coming from partial design than from that page content authors cannot change the datasource for the item. The datasource can only be set on the partial design itself.

But lets assume there is a requirement to design a product detail page with using partial design. A rendering should be there in the partial design that must pick the content from product item field itself.
The question is does SXA has any solution?

Findings

Let’s start from Sitecore configuration, showconfig.aspx contains following resolvers to resolve rendering datasources:

SXA-datasource-2

Figure 2: SXA pipeline processors to resolve datasource for renderings

There are six resolvers but in this post I am I will cover the three processors highlighted in the box.

1. Field Datasource
A field name from Context Item can be given in datasource and SXA will do following:

  • If the field type is link field than the target item id will be used as datasource.
  • If the field type is not link field and field value is not empty than field raw value will be used as datasource.

This method of datasourcing can solve the problem discussed for product detail page design in the motivation section.

Pipeline Processor:
<processor type="Sitecore.XA.Foundation.LocalDatasources.Pipelines.ResolveRenderingDatasource.DatasourceFromField, Sitecore.XA.Foundation.LocalDatasources" patch:source="Sitecore.XA.Foundation.LocalDatasources.config"/>

Syntax:
field:{FIELD NAME}

Example:
field:Title

2. Code Datasource:
A custom class can be created and type name of the class can be passed in the datasource. The custom class must implement the interface Sitecore.Buckets.FieldTypes.IDataSource. This interface contains single method named ListQuery. The method signature is as follows:

Item[] ListQuery(Sitecore.Data.Items.Item item)

As per the method signature, a Sitecore item will be retrieved as input and array of item will be returned. The resulting data source will be the IDs list of all items returned.

Pipeline Processor:
<processor type="Sitecore.XA.Foundation.LocalDatasources.Pipelines.ResolveRenderingDatasource.CodeDatasource, Sitecore.XA.Foundation.LocalDatasources" patch:source="Sitecore.XA.Foundation.LocalDatasources.config"/>

Syntax:
code:{FULLY QUALIFIED TYPE NAME}

Example:
code:SXA.POC.DataSources.CodeDataSource,SXA.POC


3. Page Relative Datasource
Instead of giving the full path of the item, a relative path can be passed that will be evaluated in respect of the Context Item, SXA will get the full path of the context item, appends the relative path mentioned in datasource at end and creates a full item path. This new full item path will be used as datasource value for the rendering. This resolver is used for the Relative Data Source item I mentioned in motivation section.

Pipeline Processor:
<processor type="Sitecore.XA.Foundation.LocalDatasources.Pipelines.ResolveRenderingDatasource.PageRelativeDatasource, Sitecore.XA.Foundation.LocalDatasources" patch:source="Sitecore.XA.Foundation.LocalDatasources.config"/>

Syntax:
page:{RELATIVE PATH}
local:{RELATIVE PATH}

Example:
page:/contact-us

Sample Code

Let’s create a sample to verify the above discussion.

To keep it simple I am creating a simple view rendering that will only render the datasource value and nothing else. Here is the rendering code:

<p>Datasource value is = @RenderingContext.Current.Rendering.DataSource</p>

1. Page Relative Datasource
I have few items created under the home page and one of those is “About Us” page. I have placed the rendering on home page and used the relative page path in data source.

SXA-datasource-3

Figure 3: Page Relative Datasource assignment in presentation

Once published we can see the full item path on the page:

SXA-datasource-4

Figure 4: Page Relative Datasource result

2. Field Datasource
I have placed the rendering on the home page and used the field data source method and used the field name as “title”.

SXA-datasource-5

Figure 5: Field Datasource assignment in presentation

Once published we can see the title field value on the page:

SXA-datasource-6

Figure 6: Field Datasource result

There is no sample in this post with a link field but that is easy to do. You can add a link field to the page template and assign it a target Sitecore item. After that just go to the presentation details and change the field name to your link field name, publish all changes and open the page, you will see the item id of the item selected in link field.

3. Code Datasource
Let’s first decide what should the custom code must perform. For simplicity I want to build a custom code functionality that will treat all children item from the context item as datasource. Let’s add a custom data source class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Buckets.FieldTypes;
using Sitecore.Data;
using Sitecore.Data.Items;
namespace SXA.POC.Datasources
{
  public class CodeDataSource : IDataSource
  {
    public Item[] ListQuery(Sitecore.Data.Items.Item item)
    {
      var l = newList<Item>();
      if (item.Children != null)
      {
        foreach(var child in item.Children)
        {
          l.Add(child asItem);
        }
      }
     return l.ToArray();
    }
  }
}

Build the solution and publish.

At the Sitecore end we have two items under the home item, let’s check their IDs first.

SXA-datasource-7

Figure 7: First child item under home

SXA-datasource-8

Figure 8: Another child item under home

Now let’s place the code source in the rendering data source:

SXA-datasource-9

Figure 9: Code Datasource assignment in presentation

Once published we can see the IDs of children pages on the home page:

SXA-datasource-10

Figure 10: Code Datasource result

Conclusion

Sitecore provides several ways to assign data source to a rendering. The existing data souring ways include providing full path of the Sitecore item, providing a Sitecore item ID or writing a query. SXA adds some new ways for data souring and gives more flexibility and power to the Sitecore architectures to design the solution.

Migrate Sitecore SQL databases to Amazon RDS

This blog post will guide you to migrate Sitecore SQL Server databases to Amazon RDS.

Unfortunately, you won’t be able to directly use the MDF and LDF files in AWS at the moment so to migrate SQL database to Amazon RDS we are going to use SQL Azure Migration Wizard. Follow below steps for migration –

  1. Before starting migration please make sure
    1. You are able to connect to Amazon RDS. To check it you can utilize SQL Server Management Studio
  2. Down SQL Azure Migration Wizard tool
    1. Extract the downloaded zip file and open SQLAzureMW.exe file.
  3. Start migration
    1. Once you open SQLAzureMW.exe. you will see a page like shown in below image. In this step you have to select process. Since we are migrating Sitecore database so we will select Database under Analyze/Migrate. For Target Server dropdown list select Azure SQL Database and click next
      1Script Wizard<br /><br /><br /><br /><br /><br />
Select Process<br /><br /><br /><br /><br /><br />
Select the process you want the wizard to wak you through.<br /><br /><br /><br /><br /><br />
SQLAzureMW<br /><br /><br /><br /><br /><br />
This wizard gives you the options to anayzes, generate scripts,<br /><br /><br /><br /><br /><br />
and migrate database schemas and data from:<br /><br /><br /><br /><br /><br />
1) SQL Server to Azure SQL Database.<br /><br /><br /><br /><br /><br />
2) Azure SQL Database to SQL Server<br /><br /><br /><br /><br /><br />
3) Azure SQL Database to Azure SQL Database<br /><br /><br /><br /><br /><br />
It will also anayze SQL Profiler trace files and TSQL script for<br /><br /><br /><br /><br /><br />
compatibiltö,' Sues with Azure SQL Database.<br /><br /><br /><br /><br /><br />
NOTE: You must be DB Owner in order to anayze or migrate a<br /><br /><br /><br /><br /><br />
database.<br /><br /><br /><br /><br /><br />
Target Server<br /><br /><br /><br /><br /><br />
Anayze Onty<br /><br /><br /><br /><br /><br />
O SQL Profiler Trace File<br /><br /><br /><br /><br /><br />
O TSQL Folder<br /><br /><br /><br /><br /><br />
Anayze / Migrate<br /><br /><br /><br /><br /><br />
@ Database<br /><br /><br /><br /><br /><br />
O TSQL File<br /><br /><br /><br /><br /><br />
Run TSQL without Anayzng<br /><br /><br /><br /><br /><br />
O TSQL File<br /><br /><br /><br /><br /><br />
Server Maintenance<br /><br /><br /><br /><br /><br />
O Maintenance<br /><br /><br /><br /><br /><br />
Azure SQL Database<br /><br /><br /><br /><br /><br />
< Back<br /><br /><br /><br /><br /><br />
Next >
  4. Choose Source database
    1. This step allows you to choose the source database. First connect to your SQL server database by providing connection details. Once database server is connected successfully select source database and click on the button that says ‘Next.’ Please see below image
      5
  5. Choose action
    1. Once source database is selected then in this step select an option named as ‘Script all database objects’. This option can enable to do the complete migration of the database. But if you don’t want to migrate entire database then you select an option that says ‘Select specific database objects.’ Please see below image
      3
  1. Create SQl script
    1. Tool will create script of selected source database for the objects selected in previous step. You should save the script on local hard drive and the move ahead by hitting a click on a button ‘Next’.                         4
  2. Select Destination Database
    1. In this step provide your Amazon RDS server details and connect it. Once connected select the target database. If you have not created any database earlier, then create a new one using Create Database option and go next
      2
  3. Final Step and Review Target server Response
    1. Once you hit next in above step migration will start and you can review result of migration in this step. You can now connect to RDs database using your SQL Server Management Studio and check all the migrated data.  This tool will save a lot of time.
      6

      You may see below errors in migration report
      StoredProcedure [dbo].[aspnet_Setup_RemoveAllRoleMembers] — sp_helpuser is not supported in current version of Azure SQL DatabaseTo make sure there is no problem in migrated database because of above error I recommend connect to RDS database and make sure Stored Procedure  aspnet_Setup_RemoveAllRoleMembers is there.

Sitecore User Group Jaipur Successfully Launched

sugimg

The First Meetup organized by Sitecore User Group Jaipur

SUGJPR or the Sitecore User Group Jaipur organized their first ever technical meetup in Jaipur on November 19, 2016 from 2 p.m.-6p.m. at Hotel Sarovar Portico, Vaishali Nagar. The entire event was sponsored by Unicolumn Software Private Limited, which is a digital agency established in 2011 and a pioneer in the field of Sitecore development.

Why SUGJPR?

The founders talked about why they have come up with SUGJPR. And the reason is to foster use of Sitecore development. The platform aims to connect developers and people who have interest in learning new tips and tricks about Sitecore development.

Founders –

Topics and Presentations – 

Sitecore® Experience Platform™ – How you can own experience (Presented by Jagmohan Rathore Sitecore MVP 2017) 

The meetup event started with a presentation on Introduction to Sitecore where we explore the power of Sitecore and learn Features and talked about the need of using a CMS, what Sitecore is, how it brings a lot of opportunities for developers, content writers as well as marketers. The features, which make it such a desirable asset for large enterprises were also talked about such as managing multiple websites, using content between different websites, multi-lingual, drag and drop functionality, SEO optimization, automated deployment, easy integration of APIs, AB testing, Sitecore Analysis, etc.

The idea was to make the audiences aware of what Sitecore CMS is and how its ample amount of features could actually be very beneficial for your businesses.

Getting started with Sitecore – Building A Very Simple Website (Presented by Mahendra Shekhawat and Gaurav Agarwal) –

Basic of Sitecore installation, configuration and tuning of Sitecore in .NET environment, design and implement templates & layouts for a very simple website. Both gave a demo on how to build a website using Sitecore, which involved the basic functionality of the platform, hosting and accessing tools.

Networking Break -

The SUGJPR meetup event included a short networking break where students, developers, core organizers and others from the audience took some time to interact and connect with each other while enjoying snacks with tea or coffee.

Sitecore Experience Accelerator (SXA) (Presented by Vipin Banka)-

Later in the day, Vipin Banka, Solution Architect at Unicolumn and a Sitecore certified .NET developer 6.0, introduced Sitecore Experience Accelerator (SXA) to the audience. He also gave a detailed demo on the installation process and use of SXA among developers and content editors

Whats Next?

Next meet up is plan in the first quarter of 2017, So please stay tune and join us on Meetup –

https://www.meetup.com/Sitecore-User-Group-Jaipur-Meetup/

Thanks

First ever Sitecore Technical User Group Event in Jaipur by SUGJPR

SUGJPR happy to announce our first upcoming event on Saturday, November 19th, 2016 from 2.00 PM – 6.00 pm. Venue - Hotel Sarovar Portico Vaishali nagar, Jaipur

SUGJPR

Agenda: 

  • Sitecore® Experience Platform™ – How you can own experience -Explore the power of Sitecore and learn Features, Uses of Sitecore and how it is better then other CMSs.
  • Getting started with Sitecore – Building A Very Simple Website – Basic of Sitecore installation, configuration and tuning of Sitecore in .NET environment, design and implement templates & layouts for a very simple website.
  • Sitecore Experience Accelerator (SXA) -A set of toolings and processes to allow the rapid creation of websites by increasing the amount of work that can be done in parallel.

schedule Details- 

  • 2:00PM – 2:15PM – Welcome/Registration
  • 2:15PM – 2:30PM – Introduction
  • 2.30PM – 3:15PM – Presentation – Introduction to Sitecore® Experience Platform™
  • 3.15PM – 3:30PM – Break
  • 3:30PM – 4:15PM – Presentation -Getting started with Sitecore – Building A Very Simple Website
  • 4:15PM – 4:45PM – Snacks and Tea
  • 4:45PM – 6:00PM – Presentation -Sitecore Experience Accelerator (SXA)

Please join us  – https://www.meetup.com/Sitecore-User-Group-Jaipur-Meetup/events/235463719/

If you have any questions. Please contact us -

  • email – sitecoreugjaipur@gmail.com
  • Mahendra - +91 92525 82898
  • Gaurav - +91 80581 54358
  • Office - 0141-2358028