How is is $lbogs defined? Have you defined the variable somewhere? It needs to be an iterable expression.
The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable (PHP: foreach - Manual)
Please post code blocks within three backticks on a separate line before and after the code block to format your code and make it more readable. Thanks.
There is a typo, pagenate must be paginate, with an ì`.
Also, your when method doesn’t make sense, because you are not filtering by the variable $filterBy, but by a harcoded value. Is the $filterBy variable defined?
Again: Please post code blocks within three backticks on a separate line before and after the code block to format your code and make it more readable. Thanks.
I posted a screenshot above how to format your code.
I assume you want to fetch the children of the community page? Then your order of code is wrong, because you are trying to fetch the children of the current page, not of the community page.
Also, because $page is this special variable that refers to the current page, it makes sense to use a different variable if you want to store another page.