On recent occasions I needed to create some content below the "For this page" or "For this block" folder in Optimizely Content Cloud. I couldn't Google the answer straight away so this post is a note to self on how to get the "For this page" or "For this block" content reference in Optimizely Content Cloud. 

// Get the "For this [content type]" folder to create content under
var contentAssetHelper = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
var forThisContentFolder = contentAssetHelper.GetOrCreateAssetFolder(e.Content.ContentLink);

// Create content
var contentInForThisContentFolder = contentRepo.GetDefault<SomeBlock>(forThisContentFolder.ContentLink);

Since I want to be able to find this again the next time I search I am going to say that this post describes how to find the "For this page" or "For this block" content reference in Optimizely Content Cloud :).


Comments

Recommendations for you