ContentProvider examples for #EPiServer Part two

Sometimes you want to customize your mirrored content, in this example I can customize the url segment, setting the ACLs, and localization. And we do use Fetchdata.

This blog post covers an other way to build up the mirrored page.

This is a continuation of the previous blog post:

Contentprovider example for #EPiServer, Former PageProvider, Part one

Sometimes you want to customize your mirrored content, in this example I can customize the url segment, setting the ACLs, and localization. We do use Fetchdata from instead of setting all properties or using CreateWritableClone(), when FetchData is used it is important to set the property PageShortcutLink to the original ContentLink.

Contentprovider example for #EPiServer, Former PageProvider, Part one

Content Providers in EPiServer is a way of publishing external data as pages/blocks etc… but also a way of publishing content in several places on your web.

Last year I upgraded our web from EPiServer CMS 6 to 7.19, and later on to 8. One big breaking change was the Page Provider changing to Content Provider. I had big problems finding providers working for us. Not even the ClonedContentProvider from Alloy did work for us. Thats why I publish our solution of a ClonedContentProvider. The major difference in our version is that we don’t use GetDescendentReferences and ResolveContent, instead implementing ListMatchingSegments.

Content Providers in EPiServer is a way of publishing external data as pages/blocks etc… but also a way of publishing content in several places on your web. Due to the lack of publishing in several containers/parents, this is a way of cloning data and keeping friendly urls.

http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Providers/Content-providers/

Registering a provider in webconfig / episerver

To not filter by Category, use -1.

ClonedByCategoryContentProvider

Continue reading “Contentprovider example for #EPiServer, Former PageProvider, Part one”

Google Recaptcha and EPiServer.Forms

Forms 3.0.0, CMS 9.12, MVC

Last night I played with EPiServer Forms. And there is a sample pack to install as Eric Herlitz blogs about, for the moment containing a calender picker and Googles Recaptcha, real neet!

Install the EPiServer.Forms.Samples: http://www.herlitz.nu/2016/08/30/add-the-missing-date-time-field-in-episerver-forms/

The RecaptchaElementBlock as it is, needs to have specified a sitekey and secret key (Register at https://www.google.com/recaptcha/ to get your keys)

I found it unfortunate that the editors needed to fill in and remember the keys every time, so i found out a way to set them automaticly when the element block is created thanks to Alf Nilssons sample code on github. (by the way setting Allow Anonymous on Forms is a prefered default)

https://github.com/alfnilsson/EpiserverForms/blob/master/Toders.Forms.Web/Business/Forms/AllowAnonymousSubmissionDefault.cs

My code:

 

Disabling EPiServer Scheduled Jobs programmatically in non production environment

Scenario: You just have copied the Production Database to your development server or to the testservers but you don’t want that some important jobs to be activated and running in the background on a non production environment.

Solution: Automatically disable EPiServer Scheduled Jobs programmatically in the initualization.

Following Māris Krivtežs blog post which describes greatly how to work with scheduled jobs. http://marisks.net/2015/05/04/episerver-working-with-scheduled-jobs-programmatically/

My code:

How to determind production server or not:

Explanation: If you are using Config Transforms and any automatic deployment system, in my case Octopus, the “Environment” appsettings is set in the transform config. eg

A second possibility is to check the MachineName.

More about scheduled jobs: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Scheduled-jobs/Scheduled-jobs/