Try our conversational search powered by Generative AI!

Global Templates

Vote:
 

Hi,

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.

Thanks

Jon

#132969
Aug 21, 2015 15:51
Vote:
 

Hi,

What is a global template?

#132975
Aug 21, 2015 16:53
Vote:
 

Hi,

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.

Jon

#132976
Aug 21, 2015 16:58
Vote:
 

I guess you could achive the same with local blocks, or by creating and then adding blocks to the page in the CreatedContent event.

#132978
Aug 21, 2015 17:01
Vote:
 

Hi, What are local blocks?

#132980
Aug 21, 2015 17:03
Vote:
 

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.

#132982
Aug 21, 2015 17:07
Vote:
 

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.

David

#132986
Aug 21, 2015 19:02
Vote:
 

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)
                {
                    writablePage.RightColumn.Items.Add(new ContentAreaItem()
                    {
                        ContentLink = BlockReference
                    });

                    contentRepository.Save(writablePage, SaveAction.Save);
                }

            }
        }

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?

#139121
Edited, Sep 25, 2015 12:21
Vote:
 

Hi Ron

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.

David

#139136
Sep 25, 2015 12:28
Vote:
 

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...

#139145
Sep 25, 2015 12:33
Vote:
 

What do you mean by not 'recognized'? If the property is null, you have to instatiate it.

#139154
Sep 25, 2015 12:44
Vote:
 

var writablePage = myContent.CreateWritableClone() as ContentPage;

and you might need
writablePage.RightColumn = new ContentArea();
if it's null.

#139200
Sep 25, 2015 13:56
Vote:
 

Ah that's it, i tried any combination except this one...Thanks!

#139201
Sep 25, 2015 14:00
Vote:
 

Hi all

I know this is an old thread but wanted to make sure people know that Instant Templates is now available:

http://geta.no/blogg/episerver-instant-templates/

David

#143214
Jan 15, 2016 13:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.