Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Get PropertyGroup programmaticly

Vote:
 

Hello

I have problems to fetch PropertyGroups programmaticly and I dont know if I'm not understanding or if its a bug. I'm using PTB 1.9.2.0 and EPi 6 R2 and I have a Propertygroup that looks like:

 

public class MyPropertyGroup : PageTypePropertyGroup
{
[PageTypeProperty(Type = typeof(PropertyPageReference), SortOrder = 10, DisplayInEditMode = false)]
public virtual PageReference FavoriteProperty { get; set; }

.

.

}

in my "main page" I do:

[PageType("<someguid>", Filename = "<some view path>", SortOrder = 1830)]
public classMyMainPageType : <BasePageType>,<Some interfaces>
{
[PageTypePropertyGroup(StartSortOrderFrom = 50)]

public virtual  <My return Property of propertyGroup>  FavoriteProperty { get; set; }

.

.

}

 

The problem I have is I have to fetch this property programmaticly from a pagedata extension method that has signature:

public static TProperty GetGroupPropertyValue<TPageData, TProperty>(this TPageData pageData, Expression<Func<TPageData, object>> expression)
where TPageData : TypedPageData, <Some interfaces>

 

and in that method I do:

 var value = pageData.GetPropertyValue<TProperty>(<nameOfProperty>); <nameOfProperty> is gotten in method by string manipulation and is in this case "MyPropertyGroup"

even if I can see that this property is set in editmode this method above returns null and I cant figure out whats wrong and will be happy if anyone could point me in right direction what to do to get PropertyGroups programmaticly

 

Regards!

#59798
Jun 28, 2012 8:39
Vote:
 

I'm not quite sure I follow but here are some things that might lead you in the right direction:

You're getting a property group wih the extension method GetPropertyValue. For property groups there is another extension method called GetPropertyGroupPropertyValue.

The name of the property that gets created consists of what you name the property group in your page as well as the actual property defined in the group. Let's say you have a property group called MyPropertyGroup with a property called MainBody. On your page type you add the property group MyPropertyGroup and name it ContactInfo. The property would then (if you look at it on page type in admin mode) be called ContactInfo-MainBody.

Does that help?

#59799
Jun 28, 2012 9:11
Vote:
 

Hello

 

Is  "GetPropertyGroupPropertyValue"-extension-method supposed to be in PageTypeBuilder.PageDataExtensionMethods? Cant find this e-method in PTB 1.9.2?

 

Thanks!

 

#59804
Jun 28, 2012 11:32
Vote:
 

Hmm, that may have come in v2 then (although I'm not certain). The methods themselves are in PageTypeBuilder.PageTypePropertyGroupExtensions.

#59806
Jun 28, 2012 12:53
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.