Multisite approach is well known topic for all Sitecore guys. Not even for them (or us I should say :)), but also for also for marketing guys and every person which has connections with managing a big site.
Today I would like to say more about creating multisite solution in context of SXA. Each of us who worked with SXA had an opportunity to see cloning mechanism in Sitecore content editor which we can achieve from context menu. For everyone else it's look like:
When we are starting developing usually we operating with one site, which we are extending. But then come a moment when client needs more than one site. There is no a problem when we have to make 1,2 or 3 sites more. But question what if we need to create e.g. 25 new sites? Would you like to make it manually? :)
Moreover we can assume that it has to be done on more then one environment. It going to extend time or preparation this by manual work many times.
Answer for this issue and solution is to automate this action. As we hear many times, if you have to do something more than once, you should to automate this.
Basing on that and on SXA we can start to digging and creating a solution to make it happen!
Cloning site with SXA is nothing else than use already prepared Powershell scripts from SXA guys, which this cloning make true. Hence, we as a developers can use those scripts and make more complex and useful for us.
Scripts which are out of the box we can find here:
As you can see there is more scripts than we are looking for. Maybe it will be useful for you in the future. At this moment we will focus on SXA scripts and their cloning sites mechanism which are a bit below than last image shows.They are exactly here:
As we see, we have functions like "Copy-Site" or "Clone Site" which position which aggregates a functions from below node and represents context menu option. Let's check how does it look inside, what we can find here:
to better understanding lets put it in VS Code:
At first look we see usage of internal functions, managing dialog box etc. So right now we don't have any obstacles to make it something on our own.
Firstly let's think a bit and answer on question: How we will pass data to our new script? An idea could be prepare some csv file which you will iterate and in that way create as many sites as you want to have.
Additionally we can do some improvements and create already some languages, some accounts for new sites needs. In my example we have also some nodes aggregating sites to regions, but of course it is not necessary.
In that way we can define columns and below rows with values:
Then we can start to create some functions on our own which we will put to Modules and scripts nodes later in Sitecore. It will be done in the same way as e.g. SXA catalog is prepared but of course you can create you own catalog to make better separation. Take a look on below script. There you will find options for setting page designs etc. Maybe it will be some inspiration for your cases as well.
I hope so :) Enjoy !
Cheers !
No comments:
Post a Comment