Try our conversational search powered by Generative AI!

Oskar Zetterberg
Sep 19, 2012
  8694
(1 votes)

PageTypeBuilder 2.0 with EPiServer CMS 7 Preview

This is a long overdue post about getting PageTypeBuilder 2.0 working with EPiServer 7 Preview.

I´m not sure the changes I made is the best or even correct, but they work. Joel Abrahamsson, please comment on this.

 

Lets begin.

Get the source for PageTypeBuilder 2.0

Update the references from EPiServer CMS 6 to CMS 7.

Changes have to be made in three files, TabDefinitionUpdater.cs, PageDefinitionUpdater.cs and PageTypeRepository.cs.

 

First up, PageTypeRepository

Add a new private member to the class and add a constructor

private EPiServer.DataAbstraction.IContentTypeRepository _contentTypeRepository;
public PageTypeRepository()
{
_contentTypeRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentTypeRepository>();
}

In each of the Load methods (should be three of them) change PageType.Load(arg) to

var pageType = (PageType)_contentTypeRepository.Load(arg).CreateWritableClone();
where arg is string name, Guid guid or int id.

Last change IEnumerable<IPageType> List() from

PageType.List().Select(pageType => new WrappedPageType(pageType)).Cast<IPageType>();

to

return _contentTypeRepository.List().Select(pageType => new WrappedPageType((PageType)pageType)).Cast<IPageType>();

Now, compile and you will get four errors about ambiguous references due to referencing the new EPiServer dll. Clear them up by adding changing

ITabDefinitionRepository to PageTypeBuilder.Abstractions.ITabDefinitionRepository where the errors occurs.

Compile again and you will have a working PageTypeBuilder although there are 78 warnings all of them marking obsolete methods or calls.

That’s it.

 

 

 
Sep 19, 2012

Comments

Tore Gjerdrum
Tore Gjerdrum Sep 20, 2012 02:04 PM

Hi Oskar,

Nice blog post! Helped me a lot!

Just one question. Which build version of EPiServer did you perform this upgrade against? Versjon 7.0.449.1?

Regards, Tore

Oskar Zetterberg
Oskar Zetterberg Sep 20, 2012 02:44 PM

Glad to be able to help. I used the public preview, 7.0.449.1. It should work with more recent versions as well as the only big change I made is to use the IContentTypeRepository.

Tore Gjerdrum
Tore Gjerdrum Sep 24, 2012 10:29 AM

Hi again,

I am using the 7.0.524 version. Everything compiles, but I get an error when trying to run the site. Did you upgrade the site or did you start from scratch?

Multiple custom attributes of the same type found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.AmbiguousMatchException: Multiple custom attributes of the same type found.

/Tore

Anders Murel
Anders Murel Sep 24, 2012 04:05 PM

The problem is that we're using the obsolete attribute PageDefinitionTypePlugin in several of our referenced assemblies. While I do not understand why an obsolete attribute should give this type of errors, changing it to PropertyDefinitionTypePlugin solved this error.

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024