Dette er CodeArts blog. Vi deler thought-leadership og tekniske tips og tricks - men som regel på engelsk.
When best practice isn't the best - Dependency Injection and Optimizely CMS
Some people live and breath 'best practice' development. I am not one of them. Risk is, in-experienced developers (or sometimes experienced) might use them just cause they are 'best practice' and not think more about it. Even when it turns out they are not. Here is little example...
Preview multiple Visitor Groups directly while browsing your Optimizely site
Visitor groups are great - it's an easy way to add personalization towards market segments to your site. But it does come with it's own set of challenges if used intensively. For example it can be hard to predict how any given page will look for visitors with a specific combination of visitor groups - and viewing it in a proper way often requires more than what you see in the quick preview mode. Here's a bit of code that will help you out.
Optimizely CMS: List content recursively on a page - and list the visitor groups used
Quite often a lot of the content on pages in Optimizely Content cloud (aka Episerver CMS) is structured in blocks placed in content areas. And often even blocks in blocks. Sometimes it's needed to quickly get a list of all the content items on a page - and sometimes you might also be interested in which visitor groups are used. Here is a couple of extension methods to help you with that.
Listing all endpoints in Optimizely CMS 12 / .NET 5
Routing has significantly changed in .NET 5 - and that affects many parts of Optimizely (Episerver) CMS 12. For example we have to get used to endpoints a middleware. As I am working on upgrading a few different add-ons I found it could be useful to see which routes are registered out of the box.
Anti-Pattern: Don't modify Optimizely CMS (Episerver) content objects in the Controller
Using your content object (CurrentPage / CurrentBlock) as a makeshift viewmodel where you change settings or extend it with user data in the controller before passing it to the view, is unfortunately (and to my surprise) a pretty wide-spread practice among developers implementing Optimizely (Episerver) web sites. But it really needs to stop.