X3 extension question

Vote:
 

Hi,

I'm trying to do the following with X3 within EPiServer:

1) Define page A which has an extension area, drag in X3 controls and save and publish the page

2) Define page B, which gets page A, and then accesses the X3 controls defined on page A, and render them out on page B.

I've got this far (the code residing on PageB):

// Get PageA from within EPi
PageReference pr = CurrentPage["PageA"] as PageReference;

// Get the extension data for PageA
ExtensionPageData epd = ExtensionPageData.Load(pr);

// Get the extension area that we want
ContentAreaData data = epd.GetContentAreaById("ExtensionAreaName");

if (data != null)
{
    // get the ContentFunctionData for that
    List<ContentFunctionData> list = data.ContentFunctions;
}


I'm not too sure what to do at this point, i.e. how to grab the data from the X3 control (the ContentFunctionData).

Any help would be greatly appreciated.

Thanks

#26049
Nov 18, 2008 17:43
Vote:
 

The data is stored inside extension properties in your content function so you can use something like:

foreach (ContentFunctionData functionData in list)
{

//functionData is lazy loaded.
functionData.Load();

//access each property by indexer (check values first)
heading = functionData.Property["Heading"].ToString();

//OR iterate properties
foreach (PropertyData property in functionData.Property)
{
//do something with properties
}

}

#26084
Nov 19, 2008 17:02
Vote:
 

Hi Rachel,

Thanks for your help, that gets me a step further towards what I'm trying to acheive, but I still have one more thing that I need to do.

functionData.Load() presumably loads in the property data into the functionData object (from the underlying DB). I can then go through and get the PropertyData for functionData, but I don't really want to deal with these properties in isolation, instead I want to load in the actual control and render it out, if that makes sense.

In other words what I'm looking for is a method whereby I could say something like: LoadControl("path to ascx", functionData), and this would load in the X3 control, populating the fields in there with the data held in functionData's Property object.

I would imagine that this is what's happening under the covers in X3 - that the EpiServer page loads, X3 grabs the ExtensionPageData object, and then loads in the controls for each extension area somehow, initializing them with the correct property data to allow them to render the correct contents.

This is what I'm trying to do, do you have any further input as to how I might get this done?

Thanks again

#26087
Nov 19, 2008 19:28
Vote:
 

If you have the ContentFunctionData this should work..

ContentFunctionData func.....
Control ctrl = LoadControl(func.ControlPath);
((BaseContentFunction)ctrl).ContentFunctionData = func;

#26556
Dec 10, 2008 23:28
Vote:
 

Hi Graeme.

This sounds like something that EPiServers "Fetch Data From" might solve. Is it possible to use that EPiServer fiunctionality, or are your demands different?

BR
Fredrik Karlsson
Dropit/cmsapps.net

#26573
Dec 11, 2008 16:34
* 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.