Skip to main content

How to style Sitecore SXA sites with Creative Exchange Live

It has already been passed 2 years from first Sitecore SXA version release.  It became more popular in time and reached enough maturity. We were thinking to use for a project and finally, I found an opportunity to try it. 

There are already some good tutorials about using Sitecore SXA and Creative Exchange Live but I want to share my experience and give some keynotes about them, especially Creative Exchange Live.

I've used these versions in my example:
  • Sitecore Experience Platform 9.0 rev. 180604 (9.0 Update-2)
  • Sitecore PowerShell Extensions: full 4.7.2 version (CM)
  • Sitecore Experience Accelerator 1.7 Update-1

Setup Notes

  • Import PowerShell Extesions before SXA package
  • Restart the Sitecore Client and Restart the Sitecore Server before close import wizard
  • Rebuild indexes
Note: If you have a publish error, contact with Sitecore Support. I had and they provided me a patch to fix that issue. I cannot share that patch at the moment because the fix is needed more tests and they didn't want to share it as a complete solution for now. 

SXA and Creative Exchange Live

I won't give much detail how to use toolbox and add components. There is nothing special, drag and drop components and organize page as you want. 

The more interesting part is on styling. And Creative Exchange Live makes the life easy at this point!

You should follow these steps to be able to work with Creative Exchange Live properly:

1. Choose "Create new theme" option and select Basic2 template as usable while creating site 



This is the note in Official Sitecore Documentation, so don't forget to add Basic2 template:


2. Open Experience Editor, click Export button on Experience Accelerator menu and download the zip file created


3. Open Site Theme folder with a text editor (I use Visual Studio Code)

I assume that node.js and npm are already installed. If not, install them first. 

Then, update server option in config.js file, mine is below:


If gulp is not installed yet, install it with this command: 
npm install --global gulp-cli

After installation, you're ready to make changes!

Let's add a new style for a custom component. I've already created a new component called "Custom Carousel". 


I've added a sass file for my new component like other sxa components. Then, compile sass files with this command: gulp sassComponents
First it will ask you to enter Sitecore credentials and then will create css files:


Then, tell gulp to watch changes with this command: gulp css-watch
After this, all changes you make in css files will be uploaded to server.


Here it is, see new created css file in sitecore:



You can see our new background color on page.

 

For the other possible options and commands, see readme.md file.

Cool! We added new sass and css files to website. 

But what about to add a new class to a sxa component?

Let's continue...

As you see the picture above, I've added a Title component to page which shows website name as "Site2". 

Now, I want to add a new class to that component. 

There are two ways to do that:

1- Add a style from Sitecore

You will see Style item under Presentation folder item. You can create a new style and add the component to Allowed Renderings section.


2- Add with Creative Exchange

When you export and download the site, you will get index.html file. It is a static html file and you will see components you added the page before. 

Before to make changes on html file, you can tell gulp to watch changes on html file and upload them to server with: gulp html-watch

After command, I've added a custom class called "custom-title-add" as below:


And it's directly updated on server:


Basically, Creative Exchange does the same thing what you do while adding a style. If you look the Style item folder again, you will see a new style called "CreativeExchange" has been automatically created:



And finally, because your component is added as Allowed Renderings, then you can see available custom classes in Experience Editor:


That's it! Hope, it helps someone. I will keep on sharing on SXA while I learn new things!

Comments

Popular posts from this blog

Sitecore 9 - Custom Page Events & Filtering with XConnect

This is the first article of a series. I am going to start with creating a custom page event and will show how we can fetch event data using xconnect api. Let's start with reminding demo scenario: Imagine that you have a website displaying movies. Visitors are able to see movie details and take some actions like save movie or share it.  You want to follow the visitors' activities and you want to take some marketing actions based on those activities. For example, if a contact visits a movie more than X time or she/he saves a movie, you want to send those movies to an external system. In addition, there is going to be a limit to send same movie. Such as, it will not be possible to send same movie more than 2 times.  You want to configure this as a marketing automation plan to give flexibility to your marketing managers. They should be able to add configurable rules and activities.  My first focus is movie detail page. I want to track visitors when they visit the

A React Example in Sitecore

That's true, Sitecore components are useful and provide lots of facilities. They allow to build fully flexible website. And there is not much problem using post-backs to display your contents. However, if your website has user interactions, then it could be a headache. Too many post-backs would occur a poor user experience. That's why client-side technologies are really powerful and popular for a long time. There are plenty of javascript libraries and frameworks which all try to provide better user experience in different ways. It is not a topic of this article why I chose React. There are some good articles about it (e.g. Jonne Kats' great article ). However, one of the reasons is React only focus on view part. It is not a fully framework like Angular, it is rich featured library instead. And that's what I was looking for! The idea was to benefit Sitecore server-side and React client-side power. It seems they are very good match! Let's dive into code... I&#

Sitecore 9 - Creating Custom Segmentation Rule

Predicates are important to create rules for marketing automation and segmented lists. Before going through the details, I am going to remind what I am implementing again. Imagine that you have a website displaying movies. Visitors are able to see movie details and take some actions like save movie or share it.  You want to follow the visitors' activities and you want to take some marketing actions based on those activities. For example, if a contact visits a movie more than X time or she/he saves a movie, you want to send those movies to an external system. In addition, there is going to be a limit to send same movie. Such as, it will not be possible to send same movie more than 2 times.  According to my scenario, I need a rule to filter contacts who visits a movie more than X time. Maybe, we can add one more condition there like in Y days. To creating rule will give flexibility to marketing managers that then they can easily add or remove multiple rules and proceed the