Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

How to get full TreeView from EPiServer 6

Vote:
 

Hi,

I am using EPiServer 6 with ASP.Net.

How can i get full PageTreeView (from left panel of EPiServer) in a collection or var (all PageTreeView like parent --> child --> subchild --> .... )

#132915
Aug 20, 2015 17:29
Vote:
 

I'm assuming you want to display the page tree somewhere on a content page.

There is actually a webcontrol that does this for you (<episerver:PageTree>) - see https://sdk.episerver.com/library/cms6/html/T_EPiServer_Web_WebControls_PageTree.htm

If you need the tree in a collection (e.g. to bind to a TreeView control), you could do EPiServer.DataFactory.GetDescendents(pageref_of_your_startpage) - see http://sdk.episerver.com/library/cms6.1/html/M_EPiServer_DataFactory_GetDescendents.htm. Note that this just returns a list of PageReferences, not PageData objects.

Alternatively you could do a recursive EPiServer.DataFactory.GetChildren call (this only gets the direct child pages of a given parent page, but returns a PageDataCollection that you could bind to your treeview control).

Be aware that retrieving the entire page tree may have a huge impact on performance.

#132919
Edited, Aug 20, 2015 19:53
Vote:
 

Hi Arild,

Thanks for your reply!

Using below method, i can get only full PageLink ID.

EPiServer.DataFactory.GetDescendents(pageref_of_your_startpage). But i want to get full tree with value(name of the node & Page link).

For eg: Below are the tree structure and i want to get full pagelink ID with node name (eg. Parent node 1, child 1) in a collection.

- Parent node 1

   - Child 1

       - Subchild 1

       - Subchild 2

   - Child 2

        - Subchild 1

        - Subchild 2

- Parent node 2

   - Child 1

       - Subchild 1

       - Subchild 2

   - Child 2

        - Subchild 1

        - Subchild 2

#132934
Aug 21, 2015 9:36
Vote:
 

You put the result of GetDescendents() as input to DataFactory.Instance.GetPages(). There you will get a full PageDataCollection.

#132935
Aug 21, 2015 9:55
Vote:
 

Hi Johan,

I have arroung 900 PageLink ID and i want to filter based on there node name. I'm already using below method under foreach loop to filter the data.

DataFactory.Instance.GetChildren(PageRefID);

But due to large amount of PageLinkID, the performance of website is very slow. that's why i'm asking for this.

Is there any way to get full Tree PageLink ID with Name of the node in sigle hit (for eg: below tree structure)???

- Parent node 1

   - Child 1

       - Subchild 1

             - SubChild 11

             - SubChild 12

       - Subchild 2

             - SubChild 11

             - SubChild 12

   - Child 2

        - Subchild 1

        - Subchild 2

- Parent node 2

   - Child 1

       - Subchild 1

             - SubChild 11

             - SubChild 12

       - Subchild 2

             - SubChild 11

             - SubChild 12

   - Child 2

        - Subchild 1

             - SubChild 11

             - SubChild 12

        - Subchild 2

             - SubChild 11

             - SubChild 12

#132939
Aug 21, 2015 10:16
Vote:
 

Maybe this is what your're after?

var criterias = new PropertyCriteriaCollection
{
    new PropertyCriteria()
    {
        Name = "PageName",
        Type = PropertyDataType.String,
        Value = "Parent node",
        Condition = CompareCondition.StartsWith,
        Required = true
    }
};

PageDataCollection result = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criterias);



#132940
Aug 21, 2015 10:29
Vote:
 

Thanks for your help!

I'm new in EPiServer, that's why i'm asking again n again.

Using this method "FindPagesWithCriteria", i'm getting only single page data not all tree Page ID with corresponding Node name. I want to get Full Tree PageID with corresponding node name in single hit (not require page data only tree structure require with Tree Page ID & Name of the node).

#132944
Aug 21, 2015 11:19
Vote:
 

If you need to have PageName available I think all built-in APIs require you to retrieve full PageData objects.

If your site has EPiServer Find you can use "projections" and only retrieve and transfer a few specified properties:
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Projections/

#132958
Aug 21, 2015 13:09
Vote:
 

Thanks again!

I want to get data from "tblWorkPage" table based on some PageID.

How can i write the code to access data from "tblWorkPage" table in code behind (asp.net with c#).

#132962
Aug 21, 2015 14:16
Vote:
 

It's not recommended to fetch EPiServer data directly from the database tables but if you were to do it still you could use SqlClient and a DataReader as you would with any SQL Server database table.

#132964
Aug 21, 2015 14:45
Vote:
 

Thanks Johan for your help :)

I'm still struggling to find the way to resolve this. :(

#132979
Aug 21, 2015 17:03
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.