Is it possible to create a Global Template in Episerver 8. It was possible in 6 R2 but im not sure how this can be done in 8.
What is a global template?
My apologies - I dont mean Global. In Episerver 6 R2 I could create Composer page templates which had default composer blocks already in place and all the user had to do is to over write the text in each block to create a new page. This saved them time adding the composer blocks to the page. This was ideal for News and Blog pages as the page layout would be the same.
I hope this makes sense and sorry for the confusion.
I guess you could achive the same with local blocks, or by creating and then adding blocks to the page in the CreatedContent event.
Hi, What are local blocks?
http://joelabrahamsson.com/working-programmatically-with-local-blocks-in-episerver-7/. This might be appropriate for some of the content on the page, but I guess you want content areas as well where the editors have more freedom to create whatever they want.
There is a feature on the roadmap called "Instant Templates". This should enable similar functionality to that described above. I bellieve its due to become available in the Fall 2015 release.
I really hope this 'instant templates' becomes available quickly.
Still struggling with creating a shared block at the moment the page of a certain pagetype is created:
There are several solutions on the net available but most are for Episerver 6. I try to do it now by working with the CreatedContent event. The problem is this event creates a readonly version of the page. I try to use CreateWritableClone to work with a version of the page i can modify, but strangely this version doesn't recognize the contentarea properties to put the blocks in???
public void contentEvents_CreatedContent(object sender, EPiServer.ContentEventArgs e)
// This code adds blocks to a page
if (e.Content is ContentPage)
ContentPage myContent = e.Content as ContentPage;
var contentAssetHelper = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
ContentAssetFolder folder = contentAssetHelper.GetOrCreateAssetFolder(e.Content.ContentLink);
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var writablePage = myContent.CreateWritableClone();
var blockType = contentTypeRepository.Load<DefaultContact>();
var block = contentRepository.GetDefault<IContent>(folder.ContentLink, blockType.ID, ContentLanguage.PreferredCulture);
block.Name = "My new awesome block";
var BlockReference = contentRepository.Save(block, SaveAction.Publish, AccessLevel.NoAccess);
if (writablePage != null)
ContentLink = BlockReference
The code refuses to work with 'writablePage.RightColumn' , this property is not recognized, while it does exist (myContent.RightColumn does work but is readonly)
What am i doing wrong?
CreatedContent fires after the content has been created, you could try CreatingContent instead as this fires before the content is created so may allow you to do what you want.
The problem is i have to create a block in the proper folder (the page folder of the page) and this contentassetfolder is only available after saving the content, not before...
What do you mean by not 'recognized'? If the property is null, you have to instatiate it.
var writablePage = myContent.CreateWritableClone() as ContentPage;
and you might needwritablePage.RightColumn = new ContentArea();if it's null.
Ah that's it, i tried any combination except this one...Thanks!
I know this is an old thread but wanted to make sure people know that Instant Templates is now available: