i have a requirement to add a full episerver menu tree in a block type..if i add a new page in menu it should reflect in blocktype also.
Can you try and be a bit more specific? Do you need a visual representation of the Episerver page-tree in a BlockType - e.g. for end user navigation purposes?
Casper Aagaard Rasmussen
yes exactly...i want a Episerver PageTree in BlockType..if i add new PageType in PageTree it should automatically get reflect in blockType
You need to build the logic to support that requirement. It would make sense to build some recursive logic that uses the IContentRepository's GetChildren and Get<> methods. It enables you to recursively work your way through your Episerver page tree - hint: start with ContentReference.StartPage and work down from that.
Please be aware that it potentially can get costly dependent on your page tree depth. Often, what I see is the need to list all nodes (pages in your context) beneath current page in order to provide navigation options to end users. To do this, you need to use the PageRouteHelper to access the current page your Block is currently used on. That will give you the context.
All above mentioned stuff has to be executed in the Controller belonging to your BlockType. I'm assuming you use MVC.
Hope that helped you to move forward.
Maybe you can get inspired by this code that I made on the fly. Be aware that it's not tested and only acts as a simplified example of how to interact with IContentRepository. It gives you the recursive feature but does not build the tree-structure.
public class ContentHelper
private readonly IContentRepository _contentRepository;
this._contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
public void FindDescendantsOfType<T>(ContentReference reference, ICollection<T> descendants) where T : PageData
var children = this._contentRepository.GetChildren<T>(reference);
foreach (var child in children)