Here is a piece of code which can do this for us:
1: var structure = PageDataManager.LoadPageStruct(homepage.PageLink);
2: var contentArea = structure.GetContentAreaById(AreaName.BOTTOM_AREA_ID);
3: for (var i = 0; i < contentArea.ContentFunctions.Count; i++)
5: var data = contentArea.ContentFunctions[i];
6: var contentFunction = PageDataManager.InitContentFunctionControl(ExtensionGeneric.ViewMode.ExtensionNormalMode,
7: Page, data);
10: var element = contentFunction as IListItemPosition;
11: if (element == null) continue;
13: element.IsLastElement = IsLastElement(i, contentArea);
14: element.IsFirstElement = IsFirstElement(i);
- In first two lines I'm using PageDataManager to get instance of ExtensionPageData class for homepage and then I can easily access required content area. Please note that to load data from a different page you just need to provide reference to a different page.
- Heaving an instance of ContentAreaData class (contentArea variable) I have access to the list of all content functions (contentArea.ContentFunctions)
- In lines 5-8 I'm instantiating each content function and then it can be added to the PlaceHolder which is a container for all content functions.
- In lines 10-14 I'm detecting first and last element as those elements may require some special CSS classes. You can read more about IListItemPosition interface and how to figure out which content function is first/last in my previous post.
1: private static bool IsFirstElement(int i)
3: return i == 0;
6: private static bool IsLastElement(int i, ContentAreaData contentArea)
8: return i == contentArea.ContentFunctions.Count - 1;
I think it's fairly simple but if you have any questions don't hesitate to leave a comment.