get Children of a node in any culture

Sylvain C. asked on January 4, 2020 00:32

Hello,

in my tree, I can nodes which are in English and Spanish cultures. However, some of then are not systematically translated.

I would like to access the GUID of all the children of a specific parent node, and get the available culture if the child node does not exist in this culture

Example: Parent A (in English)

  • Child 1
  • Child 3

Parent A(now in Spanish)

  • Child 2
  • Child 4

I would like all the 4 children Nodes to be returned whatever the culture. I tried m.Children.Select(s=> s.NodeGUID) but it returns only the node for which the current culture exist. Is there an equivalent to which I can attach the CombineWithAnyCulture for example?

Thank you

Sylvain

Correct Answer

Trevor Fayas answered on January 9, 2020 22:37

I don't think you'll be able to use the Children.WIthAllData method in this case, you're going to need to generate a new DocumentHelper.GetDocuments() query, using either the current page's NodeAliasPath, NodeID, or NodeGuid, as these are shared amongst cultures. NodeAliasPath will probably be the easiest, as it has a DocumentHelper.GetDocuments().Path(ParentPage.NodeAliasPath, PathTypeEnum.Children)

So your full query would look like:

DocumentHelper.GetDocuments()
.Types(new string[] { "My.PageType", "My.PageType22"})
.WithCoupledColumns(true)
.Path(ParentPage.NodeAliasPath, PathTypeEnum.Children)
.Culture(cultureName)
.CombineWithDefaultCulture(true)
.Published(!latestVersionEnabled)
.LatestVersion(latestVersionEnabled);
0 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on January 5, 2020 05:32

I've found on a DocumentQuery (DocumentHelper.GetDocuments()) that i often need to do both

.Culture(TheCurrentCulture) // Tries to get the culture passed
.CombineWithDefaultCulture() // If not found then will use the default culture
.CombineWithAnyCulture() // Will combine with any culture, this may give multiple documnts if in multiple cultures.

Some combination of those should do the trick, probably CombineWithAnyCulture()

1 votesVote for this answer Mark as a Correct answer

Sylvain C. answered on January 9, 2020 22:22

Thank you Trevor,

I am more in a case where i have node in Spanish without children on it own for this culture, but I know that the same node in English culture has children. Then I would like to get the children of the default culture if the current culture doesn't have some by itself. I am looking for a method or property to apply on children.WithAllData which returns a TreeNodeCollection containing this kind of nodes with mixed cultures.

Do you know if there is something like that?

S.

0 votesVote for this answer Mark as a Correct answer

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