Does a parent page with many child pages provide models for all children?

S1T2 Developer asked on October 17, 2019 03:22

Does a parent page with many child pages provide models for all children?

By fetching the model of a parent page, does it include all data from the child pages also? or do they all need to be retrieved separately?

Thanks!

Correct Answer

David te Kloese answered on October 22, 2019 10:57

Wouldn't just adding

.Path("/folder/links/", PathTypeEnum.Children)

do the trick?

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on October 17, 2019 10:36

Hi,

By default the API returns only object(s) you request, so no, child nodes will not be returned. But in the TreeNode there are "lazy" properties Parend and Children - if you call them this will trigger requesting parent or child nodes.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on October 17, 2019 10:46

Hi,

Where would you need this for? As by your logic getting the root would return the whole tree!

If you use the default generated code it will contain something like: DocumentHelper.GetDocuments<Article>()

Which will return a strongly typed Article list.

You can write your own object query combining data retrieval for a special case (e.g. creating a menu that consists of multiple page types). Joining multiple types and using .Result

docs.kentico.com/...RetrievingdatabasedatausingObjectQueryAPI-Joiningmultipletables(SQLJOIN)

Result - returns a DataSet containing the query results. Recommended if you need to bind the data as a data source, and for data containing columns from multiple tables (joins and unions).

TypedResult - returns a strongly typed collection of the query results (InfoDataSet

0 votesVote for this answer Mark as a Correct answer

S1T2 Developer answered on October 22, 2019 02:58

Thanks for your replies! After spending a bit more time with Kentico I realise that my needs are slightly different, and the question I asked was probably over complicating things.

What I'm really trying to do is to retrieve all pages of a certain type which have the same parent node.

Say I have a page type called 'link', and this is reused all over the place. In a particular view, I would like to be able to render a partial view that fetches all of the 'links' belonging to a certain parent node/page.

Does that make sense?

Thanks

0 votesVote for this answer Mark as a Correct answer

S1T2 Developer answered on October 25, 2019 06:08

Hi David, thanks for your help. That method works well!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.