Anders Hattestad
Jun 17, 2010
  10740
(1 votes)

Itera.Objects, a extension for PageTypeBuilder

I have been looking and PageTypeBuilder, and the concept is great. But one thing I missed was the ability to add objects of all types and not only primitives or propertydata types.

I started by downloading the latest build, and looked around. The Interceptor get’s the value of a property and set’s it on the page object. I therefore had to create a property that was a wrapper around a object.  Before I have used Itera.MultiProperty to store many variables. This time I tried to use the dynamic data store, but after a couple of hours trying to set a setting on a property from code I switch over to saving them as real properties on the page.

These properties are disabled from edit mode, and I have a container property that shows these hidden properties.

image

When Page type builder finds this stuff It will create a 2 properties. But since PTB doesn’t follow type’s I have made a IInitializableModule that follows these types, and adds the hidden properties.

image

 

The property PropertyContainer will in a context of a strong Types page create the an instance of the object and populate all the primitives from the hidden property data. If it encounter another PropertyContainer it will create that object and populate it form it’s hidden properties.

image

There is actually 5 different properties, that will display a bit differently in edit mode.

  1. PropertyContainer
  2. PropertyContainerWithHelp
  3. PropertyContainerSmall
  4. PropertyContainerSmallNoBox
  5. PropertyContainerSmallWithHelp

If you specify different tab’s for the different properties the layout will also change.

image

will display in edit mode like this:

image 

and

image

How cool is that :)

And even better, the tabs have access rights!

Code is available here

Jun 17, 2010

Comments

Sep 21, 2010 10:33 AM

Very cool!

Erik Nordin Wahlberg
Erik Nordin Wahlberg Sep 21, 2010 10:33 AM

Wow, this is really cool! To bad you did't find a way for using settings for properties via code. Have you talked with EPiServer about it?

Sep 21, 2010 10:33 AM

Thanks.
I sent a mail to Mr Smith :), but haven't got a replay. The logical step would to bind what kind of type the property should be as an value on the property setting. Instead I needed to find the PageType when you access the Value and find by reflection the type.
It could also be possible to save the inner values inside these property settings, but as it turned out there are a few benifitts of saveing them as real properties. Copy, Export and so on....
/ Anders Hattestad

Sep 21, 2010 10:33 AM

Seems like a good way to structure your pages into reusable components. Very cool!
/ Patrik Akselsson

Sep 21, 2010 10:33 AM

Wow, what a great idea and implementation.

This is, from a code perspective rather than a persistence perspective, really beginning to stretch the EPiServer model beyond simple dictionary based PropertyBags.

Probably a big ask, but is there any way to go further and allow strongly typed access to List and Collection types. This will obviously present difficulties unless those collections were serializable, but that functionality would really be valuable.

Sep 21, 2010 10:33 AM

There is a couple of ways of doing lists.
1) Itera.MultiProperty do save all sub properties as a string. The only issue is that we need a way populating the PageData object with it's value.
2) make a generic PropertyAnyClass class that use the ObjectDataStore. I have actully most of the implementasion ready, will post it as soon I can.

If any of you have managed to set a property setting on property from code, please let me know.
/ Anders Hattestad

Sep 21, 2010 10:33 AM

What email? I haven't seen anything from you Anders.
/ Paul Smith

Sep 21, 2010 10:33 AM

Guess it got cought in the crazy laughing programmer mail filter rule you have:)

was basicly a question about some example code for setting a property setting when all you had was the propertie def id

will resend
/ Anders Hattestad

Sep 21, 2010 10:33 AM

My bad.
Had an error in paul smith's epost adress , so you can stop searching your email server :)
/ Anders Hattestad

Joel Abrahamsson
Joel Abrahamsson Sep 21, 2010 10:33 AM

Really interesting stuff! Will take a closer look at it as soon as I can. I'm also very interested in your question to Paul, so perhaps you, Paul, could post your reply as a blog post?

Joel Abrahamsson
Joel Abrahamsson Sep 21, 2010 10:33 AM

Oh and I'd also love to hear more about your experiences of building on top of/plugging into Page Type Builder!

Sep 21, 2010 10:33 AM

Got an answar to how we should set properties on properties by code.
setting is the propertysetting class.

object setting=Activator.CreateInstance(EPiPropertySetting.PropertySettingType, EPiPropertySetting.PropertySettingArgument);
if (realProperty.SettingsID == Guid.Empty)
{
realProperty.SettingsID = Guid.NewGuid();
realProperty.Save();
}
var settingsContainer = new PropertySettingsContainer(realProperty.SettingsID);

settingsContainer.AddSettings(new PropertySettingsWrapper
{
PropertySettings = setting as IPropertySettings,
DisplayName = EPiPropertySetting.PropertySettingType.Name,
IsGlobal = false,
IsDefault = false
});

new PropertySettingsRepository().Save(settingsContainer);
/ Anders Hattestad

Erik Nordin Wahlberg
Erik Nordin Wahlberg Sep 21, 2010 10:33 AM

Anders! I removed a property from code, and now it crashes on startup.

Line 221: return (this.ClassAttribute.EditCaption == null ? Name : (this.ClassAttribute.EditCaption+"["+this.Name+"]")) + " (is " + this.ClassPropertyType.Name + " render as " + EPiPropertyType.Name + ")";
in PropertyInfoAndData.cs returns a null reference.

Erik Nordin Wahlberg
Erik Nordin Wahlberg Sep 21, 2010 10:33 AM

Sorry, that was not the issue.

I added a new property of the type int, but i did not declare a Type=typeof(PropertyNumber) when doing that. It caused a null reference to EPiPropertyType.

Bjørn Gustafson
Bjørn Gustafson Jul 21, 2011 03:33 PM

I saw your comment on this post, regarding PageTypePropertyGroups in PageTypeBuilder 2: http://world.episerver.com/Blogs/Lee-Crowe/Dates/2011/5/PageTypePropertyGroup-for-PageTypeBuilder-v2/

I am using PageTypePropertyGroups, but I love what you have done here by visually grouping the properties together in edit mode. Nice job! :-)

Do you have a version of your code which works with the new PageTypePropertyGroups in PageTypeBuilder 2?

Oct 20, 2011 01:43 PM

Hi Bjorn

When PageTypeBuilder 2 is officially released I will release a new version of PageTypeBuilderUI. This will contain functionality similar to what Anders has done with his Itera.Objects project to lay the property group properties out in a nicer format.

Lee

Please login to comment.
Latest blogs
Translating Optimizely CMS 12 UI components

Optimizely CMS 12 have been out for a while now, but still some elements haven't been properly translated resulting in a GUI defaulting to english....

Eric Herlitz | Jan 26, 2023 | Syndicated blog

Image preview in Optimizely CMS12 all properties view

With these simple steps, you can now see an Image and its Metadata, including size and dimensions, when editing an Image property in Optimizely...

Tomas Hensrud Gulla | Jan 26, 2023 | Syndicated blog

Setting up the ImageEditor in Optimizely CMS 12

Setting up certain configurations on Opimizely CMS 12 differs quite a bit from prior versions of (Episerver CMS 11 and older). Here's a small guide...

Eric Herlitz | Jan 25, 2023 | Syndicated blog

Happy Hour Returning in February

Hi everyone! It's been a while and we're excited to resume our Happy Hour in February for more learning, sharing, connecting, relaxing, and just to...

Patrick Lam | Jan 24, 2023

Planned breaking change for Locale parameter in Content Graph

Content Graph, a new service which makes it possible to query content using GraphQL, will have a breaking change soon. The service is currently in...

Jonas Bergqvist | Jan 23, 2023

Optimizely Advanced ContentArea Render is Back!

If you have used EPiBootstrapArea package - then back in those days we had an opportunity to render Episerver ContentArea items with different...

valdis | Jan 23, 2023 | Syndicated blog