Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How get Tree from 0 level ? #241

Open
Dmi3yy opened this issue Oct 12, 2020 · 5 comments
Open

How get Tree from 0 level ? #241

Dmi3yy opened this issue Oct 12, 2020 · 5 comments
Labels

Comments

@Dmi3yy
Copy link

Dmi3yy commented Oct 12, 2020

Some think like that:
Content::descendantsOf(0)->get()->toTree()

I want build menu with 3 level depth.

@Dmi3yy
Copy link
Author

Dmi3yy commented Oct 12, 2020

We have methods:
getRoots()
and
descendants()

but they not work together

@franzose
Copy link
Owner

franzose commented Oct 13, 2020

Hi, @Dmi3yy! Entity::descendantsOf() takes ID as an argument so unfortunately you won't achieve what you want like that. It seems that currently there's no easy way to get the tree from a particular level in one query. It's a good point to research.

@Dmi3yy
Copy link
Author

Dmi3yy commented Oct 13, 2020

One way: add 0 ancestor, without add document with id 0, than we can use descendantsOf(0), easy but not beautiful solution
https://take.ms/4GHqk

Or add one more method, we stay on this way:
https://github.com/evolution-cms/evolution/blob/9ece0741d62cb4e2b780e57483b3d26d9772491d/core/src/Models/SiteContent.php#L2174

@franzose
Copy link
Owner

Or add one more method, we stay on this way:
https://github.com/evolution-cms/evolution/blob/9ece0741d62cb4e2b780e57483b3d26d9772491d/core/src/Models/SiteContent.php#L2174

It seems you partly copied the code from my library, didn't you?

@Dmi3yy
Copy link
Author

Dmi3yy commented Oct 13, 2020

Yes, all logic from your library.

Couldn't integrate as a dependency, so added to the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants