0 Comments

image

Sitecore Experience Accelerator has been released not long ago. I guess that It is still quite new to most of Sitecore developers. Recently I was asked to implement SXA for our client. Obviously, there are many online documents about what SXA is and how SXA can be used for creating a website.   However,  It rarely has documents for developers who want to implement SXA with more advanced features.  Therefore, I decided to share my experience with SXA. 

In this post, I’m about to explain how to create custom components with SXA. If you don’t know about what SXA is,  I would suggest to read the below listed articles before going further.

As you may already know, SXA has been implement with Helix principle.  Helix principle, however,  is out of scope in this post.  If you want to get yourself familiar with Sitecore Helix, there are many resources available online.

Now, let’s start to create your own SXA component step by step together.

What we want to achieve here?

To create custom SXA component and register on the Tool bar so as to allow user to drag and drop into a page.

image

 

Getting started to create custom SXA component

Step 1 – Install Sitecore  and SXA

I’m using SXA 1.3, it requires Sitecore 8.2 rev.170407.   you can download from here.  SXA heavily relies on Sitecore PowerShell Extensions. Please make sure you has installed PowerShell Extensions 4.5 before start.

Step 2 – Setup Helix solution

Setup Sitecore Solution with Helix principle.  Sitecore also provided a sample Helix solution called Habitat on Github. Habitat is a good start, if you want to learn how to build website with Helix principle.

image

Step 3 – Create a new feature

There is no much difference for creating a SXA component. Almost the same way as you create standard component in Stiecore solution.

Rendering Controller

First, you will need to create a controller. The only difference here is that the controller need to inherit from SXA StandardController under Sitecore.XA.Foundation.Mvc.Controllers namespace as shown in below:

Rendering Model

Then, create rendering model, called ImageRenderingModel, by inheriting from SXA RenderingModelBase under Sitecore.XA.Foundation.Mvc.Models namespace as shown in below:

RenderingModel Repository

After that, next is to create a repository for retrieving data from datasource. I created a model repository called ImageRepository by inheriting from ModelRepository under Sitecore.XA.Foundation.Mvc.Repositories.Base namespace as shown in below:

Rendering View

Finally, I’m going to create a rendering view as shown in below:

Step 4 – Register Image Repository in IoC

As you can see in the screenshot below, the MediaImge controller constructor has a IImageRepository parameter. In order to inject IImageRepository into the controller,  it needs to be registered in IoC. SXA has implemented its own IocProcessor, which allows us to easily register custom repositories into the SXA IoC ServiceCollection via pipeline.

image

Here is the code for leveraging IocProcessor to register the ImageRepository.

Next, I will add the service I just created into pipeline as below:

Step 5 – Create rendering controller in Sitecore

I assumed you are Sitecore expert already, and i’m not going to explain how to create a rendering controller in Sitecore.

image

Step 6 – Add new component into SXA tool bar.

Finally, we are here.  Select presentation –> Available Renderings –> Media and select the rendering controller we just created above.

image

Congratulation, now you successfully created your first SXA component.

image

 

Hope you found this article is useful. Follow my blog, if you like it, or email me if you have any questions about SXA.

0 Comments

image

If you are using the latest EMX 3.4, you may already know that Sitecore replaced their MTA with Sparkpost.  In previous versions,  you would need to have Sitecore Application Centre credentials and an MTA subscribed Sitecore licence before you start to use Sitecores MTA. 

Now, you no longer need to access the Sitecore Application Centre as Sitecore is fully integrated with Sparkpost for EXM 3.4. Further more DKIM (DomainKeys Identified Mail) has been implement within EXM.

 

What is DKIM?

DKIM lets an organization take responsibility for a message that is in transit.  The organization is a handler of the message, either as its originator or as an intermediary. Their reputation is the basis for evaluating whether to trust the message for further handling, such as delivery.

Technically DKIM provides a method for validating a domain name identity that is associated with a message through cryptographic authentication. So instead of passing user name and password to SMTP server, it passes an encrypted key to the mail server.  This helps to keep your email campaigns out of spam folders and it ensures that others cannot use your domain without permission.

You can read more about DKIM here

 

How to configure DKIM in Sitecore?

Firstly, you will need to add domain. Purpose of adding each domain is to validate the domains that you want to use to send email campaigns. This domain is not registered within the MTA, but instead Sitecore validates the sending domain by DKIM (DomainKeys Identified Mail).

image

 

Secondly,  add the TXT records in DNS configuration.

The method of adding TXT record differs in different hosting environments, however it is as simple as adding a recording of type 'TXT' and providing the "Hostname" and "Value" i.e. a DKIM key. For more information on these records, please check this link.

Changes to domain records can take up to 24 hours to take affect.

image

If the hostname and key are valid, you should see a green tick; as per the below screen shot.

image

 

Last but not least,  you need to disable the custom SMTP configuration and enable Sparkpost configuration. This can be done by removing the suffix .disabled from the following files:

  • Sitecore.EDS.Providers.Sparkpost.config.disabled
  • Sitecore.EDS.Providers.Sparkpost.Sync.config.disabled
  • Sitecore.EDS.SparkPost.Client.config.disabled

 

Do I have to configure DKIM for different environments?

No.  Once the domain has been added against your Sitecore licence (within EXM), it will take affect for all instances using this license, regardless of the environment i.e. UAT, Production etc.

 

How to verify it’s working? 

EXM will validate the “from email” based on the domains that you registered.

image

Alternatively you can use the “Review” option and send a quick test. If all the everything is correct, you should see a message successfully sent message at the top of the page.

image

0 Comments

First of all, I would like to thank Gruden for sending me to the Sitecore Helix workshop. It’s a two days workshop, which delivers in-depth knowledge of the principles, conventions and guidelines governing solution architecture, recommended development practices, DevOps strategies and more.

 

If you are also interested in this course, you can find more details here.

 

James Hirka, Solutions Architect from Sitecore, is the presenter. I’m not going to cover all the course material here, but instead highlight some important concepts that are covered within the course.

image

 

I would like to start by proving some background about what is Helix.

  • Helix is a an official guideline, recommending a modular build for Sitecore solutions
  • Habitat is an example implementation of Sitecore, using the Helix principles.

Habitat is a great starting point of learning Helix.  You can find the Habitat solution on GitHub.

 

Sitecore Helix was derived from the concept of components in a component-based architecture; this was originally described in the book “Agile Software Development by Robert C.Martin”.  The word component refers to a module in Helix, this is really all the files, views, renderings, configuration etc. that make up a component (or module). 

 

How we define a module/component? There are two major principles:

Cohesion Principles – Granularity

The principles of component cohesion is for deciding how to partition classed into components

  • REP (The reuse/release equivalence principle)
    The granule of reuse is the granule of release

 

  • CRP(The common reuse principle)
    The classes in a component are reused together. If you reuse on of the classes in a component, you reuse them all.

 

  • CCP(The common closure principle)
    The classes in a component should be closed together against the same kinds of changes. A change that affects a component affects all the classes in that component and no other components.

and Coupling principles – Stability

The principles of component coupling is for defining the relationships between components.

  • ADP (Acyclic Dependencies principle)
    Allow no cycles in the component dependency graph.

 

  • SDP (Stable Dependencies principle)
    Dependant in the direction of stability

 

  • SAP (Stable-Abstraction principle)
    A component should be as abstract as it is stable.

Favour composition over inheritance

  • Avoid multipurpose fat interfaces
  • Think of interfaces as roles
  • Implement just the minimum interface to ensure that you only depend upon what is required
  • Only expose what is required by a specific client

 

Practice makes perfect

I hope I didn’t put you to sleep with this very technical topic, and the principles it covered, however if you would like to work through some excises and get familiar with the Helix principles, you can find some here.   

 

Recommended Readings

Apart from the Sitecore Helix official documentation, there are some good books listed below:

[1] https://www.amazon.com/Agile-Principles-Patterns-Practices-C/dp/0131857258

[2] https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882

[3] https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215

0 Comments

image

The new version (5.6.0.12) of TDS has been released in March for supporting VS 2017, which is exciting news for Sitecore developers. However,  if you installed TDS version 5.6.0.12, you may receive an error message, some thing like “cannot modify an evaluated object originating in an imported file”. If you see this, it is likely because you have modified some of the TDS project properties, within the properties window.

I’ve raised this issue with the TDS support team and they have quickly turned around an update that resolves this issue, version 5.6.0.13. You can download this here.

0 Comments

Mozilla Firefox 52 ended support for Silverlight

image

Is it matter? Yes, as we all known that Sitecore App Center was built on top of Silverlight. Since Version 42.0 Google Chrome has already stopped the support for Silverlight ( Find more Details).  However, you can still use Silverlight in Mozilla Firefox with Silverlight PlugIn. If you open your Sitecore App Centernow in Firefox, you see that the Install Microsoft Silverlight badge is displayed. When you reinstall Silverlight, the issure still occurs (See screenshot below). This is because Mozilla has ended of all NPAPI plugins except for Flash in March 2017, when Firefox version 52 is released. See this article for details. 

image

Don’t Panic!

Firefox Extended Support Release (ERS) will continue support these plugin until early 2018. Let’s pray Sitecore is ready for this transition to happen. To download the ERS click here

image

After you installed, Sitecore App Center is back.

image