Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

9:20 AM

Powershell: Remove languages version from items

I had a request to remove from project all items in some particular language version. Of course Sitecore enable option to make it manually, but it's per item. So if I would like to remove n-elements I had to click n-times whole process.

To avoid this, I thought that the best option to solve it will be Powershell :)




Moreover if you want to add some version language, it's also "no problem" for Powershell !


9:16 AM

InfoMEET Conference

June 10th I had a pleasure to be the speaker on InfoMEET conference in Wroclaw. InfoMEET is a place where many people from IT world can share their experiences and get to know more with others specializations in wide IT world.



Because of very large scope of technologies on this conference, I've prepared topic:

"Sitecore – Example of Digital Marketing Platform"

SoftServe picture

My main goal was to encourage other IT guys like students or .Net developers into Sitecore. I have described client needs and solution which Sitecore gives them on to that.



I hope for every participant this was a valuable time :)
7:37 PM

WFFM Action add contact to contacts list, extend conditions

All of us know WFFM very well and made there a lot of things. We would like today focus on particular action - "Add Contact To Contact List"

In general, this action is used to adding some contact data gathered from form and push this information as a contact to some list in List Manager. More details information is available in documentation here.

This action has very useful things - conditions:


It provides ability to create conditions based on fields you have in your form to add contact to the list. Developer see list of checkboxes what is userfriendly. 

List of checkboxes works as an 'OR' condition, so first true statement return true for whole list.

What in case when we want to have 'AND' condition and check if all selected checkboxes give true? Is it possible?

Sure, it is ! :)

I had already custom action which has been inherited from default action "Add Contact To Contact List". If you don't have this situation it's good to make it in this same way.

When we decompile this action we see:


Highlighted area on red show us part of code responsible for checking our conditions. To change it we have to take a look how it's working currently and how we can change it. Hence, during digging we see:





Selected area shows exactly, when some condition return true, the whole method return true as well. Right now, we have to think how to change it to AND condition ? I propose to create an array of results per each condition, then check if all of them return true. Since we will have that information we can decide if whole method should return true or false.





Later we have to only use our method implementation in our custom action. That's all ! It's working perfectly :)

Make conditions in that way and give content editors more possibilities :)

3:09 PM

Users migration

There is a lot of situations when we develop a new Sitecore project, but client wants to migrate old data, from previous project. We can assume that he has some really old Sitecore app as well.

One of the most important data for him are users.

What in that case?
- We have to migrate those guys.



Fortunately everybody know that Sitecore uses ASP.NET Membership structure to keep users. It's well known form, so it shouldn't be a hard work.

Here I would like to sell you some tip.

Users data contains information about users, but also about profiles which are used by Sitecore. The best option to migrate users is just use SQL scripts, but to move profile data, better is to use Powershell scripts.

I will describe SQL part, Powershell could be find on my friend blog, who cooperate with me in this task.

Below we have script which will help (I hope) during users migration. Firstly I've take care about membership, users and roles tables.



What we can notice here is word "COLLATE". Well I had this situation when old client DB had set different DB collation then new database has. Because of that I couldn't easily get that information and transfer to new table. I had to create walkaround, which became temporary tables. I transfer there data with new collation and later I could get those data and put directly where I wanted.

At the end of script I've also updated ApplicationId. I just didn't want to have mess in my tables. It's good to remember about that I think.

I hope that this information help you to smoothly migrate your users, without pain and sleepless nights :)

Take care !
10:00 AM

Dynamic insert options

Insert options, everybody know what does mean :) This is the place where we can make content editor life happier. We can prepare options in Content Editor context menu, to add new item based on some dedicated template.
It looks like image below.



Ok, so we have insert option, we have even put there some our custom template to create datasources. But what if we want to have only one instance of this item in this particular place ? Insert option allows to put as many we can, it doesn't say "Mate, only one is possible here". Is it possible to do that?

Well, yes it is :)

To make this dynamic option, we will use Rule Engine in Sitecore!

1. Rules for Insert Options.

To find rules we have to go to the path:

 /sitecore/system/Settings/Rules/Insert Options/Rules 

 In that place we can find something looks like:


To create new item, just click on Rules parent item and chose "Insert Option Rule". When we create this item, we can go to the field "Rule" and click it. This action will open a dialog when we can build our custom rule.


2. Rules Queries

Rules can as custom as we want. Only constraint can be your imagination. In our case it will be condition, if item (as an instance of our template) has been already added to this particular place, or not. To do that we can write query like:


Voilà, we have dynamic insert option in our application and new friends in content editor team :)
11:52 AM

SUGCON 2017 Memories

Few weeks ago, exactly 17th May, me and my "Sitecore" friends went to Amsterdam to SUGCON 2017. It was first time when I was attending to this event and I have to say it was really good time there. I've gather news from presentation, meet new friends and see in 'real life' old ones ;)

In this short post I would like to share with my SUGCON 2017 memories :)

First impression ?




Amsterdam of course, before Sugcon I was only on Schipol airport during transfer flights. But it was nice to visit other places :) Lots of bikes, beautiful canals and lovely architecture. After this everyone of us was in good mood to start with Sitecore part of the trip.

Conference

So many kind person which love Sitecore, the atmosphere of celebration was in the air. I've have a few talks with guys from other countries and share our experience and ideas according to particular Sitecore topics.


I have to highlight food.. nobody was hungry I assume :)

Presentations

The main part whole conference, presentation. It was so motivating to hear information about JS services in Sitecore or Publishing Services also great presentation. I hope that nobody will be angry on my but I admire Bas Lijten & Rob Habraken who has build own robot to show each conference that channels in Sitecore means everything. we can say sky is the limit. Amazing job Bas & Rob and of course say hello to Robbie :)

Afterparty

we had great opportunity get to know each other more on afterparty organized by Mirabeau
company. The made their office available for all conference attendees. It was a pleasure to be there :) Especially they serve even the food :) Really good job guys !


At the end I'm in 100% sure that was good decision to went to Amsterdam. Great place, great news and what the most important great people. We gonna meet on the next conferences I hope. Remember, if you are not sure, it means you should go!

See you there !
11:40 AM

Redirects 2/2

Hi !

It took a few days to continue the topic, but now is good time to do it :)

In part one we have created list of redirects and singleton factory provide list of redirects in Redirect Handler. But thing which hasn't been mentioned is - How to refresh list of redirects in our factory ?

1. Redirects list synchronization 

If you are thinking now like:

"What are you talking about Robert? We have a list of redirects and what special is there?" 

Please notice one thing - That list is derived from singleton factory and if we want to refresh this list, we have to take care of it by ourselves.

To achieve that we need to create Redirect Synchronization  Handler which will be responsible for refreshing our redirect lists.

So now, we have some information how to sync our list. Cool, question is, where we should to invoke this ?

2. Invoke sync action

This is the point that we are really close to finish our functionality. To make it, we have to inject our class to sync redirects in some place.

What can be the most obvious ?

We have to ask, when we want to clean and sync our redirects ? Probably when we will add new ones. Hence, if we would like to be sure that potentially new added redirect items will be sync, we have to inject our code into publishing process.

To do that we can easily create a config patch and invoke our class in publish event. Could be done like:

What we can see here is also publish:end:remote event. It's very important for this ones from you, who use scalable architecture with servers CD, CM. Don't forget to use remote event :)

At the end I hope that information I wrote will be helpful for you. Keep fingers crossed and of course feel free to write me if you would like to.