Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Get parent widget property values View modes: 
User avatar
Member
Member
rbeakhouse-nucleus.co - 7/28/2011 3:50:19 AM
   
Get parent widget property values
I have a widget which is common to all pages in a site, the widget has a property that the user can change.

If there is no value in this property set by the user I would like to use the property value in the parent page widget, this would save time by allowing child widgets to effectively inherit the parent widget value.

I'm a bit stuck on how to get this working using the api, does anyone have any suggestions/code samples?

Thanks




User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/1/2011 3:18:03 AM
   
RE:Get parent widget property values
Hi,

here is an information for readers of this thread:

You will need to create a custom form control to achieve your goal. This form control will be used in child widgets.

The scenario is following:

On a root document (or some other parent document) you can insert a widget into the editor zone widget zone (please do not use user or group widget). Insert your parent widget in the Design tab.

Now in the code of your form control you can access properties of the parent widget using following code and set it as a default value in your child widget:


        
PageInfo pi = PageInfoProvider.GetPageInfo("CorporateSite","/","en-us","",false,ConnectionHelper.ContextConnection);
PageTemplateInfo pt = pi.PageTemplateInfo;
WebPartZoneInstance wpzi = pt.GetZone("zoneLogo");

// this array list contains all webparts (widgets) from selected zone
ArrayList al = wpzi.WebParts;


Best regards,
Ivana Tomanickova