Jump to content

Recommended Posts

Posted

Hi All, I'm using the descendants() method to get all childrens, grandchildrens, great-grandchildrens, my structure is something like this:

/page/
    /article/
    /article/
    /subcategory/
        /article/

My results using: $page->descendants()

ProcessWire\PageArray Object
(
    [count] => 2
    [total] => 4
    [start] => 0
    [limit] => 0
    [pager] => 1 to 2 of 4
    [items] => Array
        (
            [Page:0] => Array
                (
                    [id] => 2
                    [name] => article1
                    [parent] => /page/
                    [template] => article
                    [title] => Article1
                )

            [Page:1] => Array
                (
                    [id] => 3
                    [name] => article2
                    [parent] => /page/
                    [template] => article
                    [title] => Article2
                )

        )

    [itemsRemoved] => Array
        (
            [0] => Array
                (
                    [id] => 4
                    [name] => subcategory
                    [parent] => /page/
                    [template] => category
                    [numChildren] => 1
                    [title] => Subcategory
                )

            [1] => Array
                (
                    [id] => 5
                    [name] => article3
                    [parent] => /page/subcategory/
                    [template] => article
                    [title] => Article3
                )

        )

    [selectors] => has_parent=1, include=all
)

I am receiving only direct descendants as long as they are empty. I'm not sure if I'm missing something or if it's not the right function.

 

Thanks!

Posted
17 hours ago, elabx said:

Are child pages published and not hidden? Does using using find() have the same issue? 

Edit: I found the problem, I was using the filter method, and that was causing the missing pages.

 

Thank you!

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...