Jump to content

Recommended Posts

Posted

Hello,

what is the behaviour of unpublished pages children?

In the admin I see them as published, but if I query them via the Api, I see an Internal Server Error ("Call to a member function children() on a non-object").

Should I unpublish children and grandchildren recursively?

Thanks... !

Posted

you can add include=all in your selector

For mass-editing stuff like hidden / published etc., use the Batcher module.

Posted

Thanks Dragan,

I don't think I got it, I need to hide programmatically a branch of pages, and with Page::statusUnpublished I see I can hide only the root page.

Is there any way to make it the easy way?... :)

Thanks!..

Posted

What?

Making a page unpublished counts only for the page itself. Depends what you need and what you mean with hide. Lots of options and contexts and terms...

Posted

For example I have

Project 1

  Links

    Link 1

    Link 2

    Link 3

  Posts

    Post 1

    Post 2

    Post 3

I need to unpublish all of these, I was wandering if there is something like $pages->delete($page, true), that is $pages->unpublish($page, true)..

Posted

No theres no unpublish($page, true)

You can use the Batcher module to mass edit pages. You'll need a selector like "has_parent=1004" id of parent...

Hello,

what is the behaviour of unpublished pages children?

The behavior of children of a unpublished parent is the same as when it's published. It doesn't influence it's children.

In the admin I see them as published, but if I query them via the Api, I see an Internal Server Error ("Call to a member function children() on a non-object").

Hard to say without seeing your code. But my guess is you have a script that tries to find the parent page but can't because it's unpublished... and you call $parent->children() somehwere but $parent isn't really a page object. that's what the error says at least.

But you still could get the parent and it's children via API even if unpublished, you just add "include=all" to the selector or just use a get

$parent = $pages->get(1004); // id of the parent
$children = $parent->children(); // works as usual, even if $parent unpublished

But it's still unclear to me what you try/need. Why unpublish them, when you want to query them?

Should I unpublish children and grandchildren recursively?
 
That's a question I can't really give an answer, as I still don't know the reason why you want to unpublish all those pages?
 
Do they need to be hidden in navigation? Where hideing the parent would be enough? 
 
I can imagine that if you really want to make them all unpublished and not reachable to unpublish the parent for the branch and control a 404 in you templates init somewhere like the head.inc.
if($page->parents("status>=". Page::statusUnpublished)->count()){
    throw new Wire404Exception();
}

Basicly checking if any parents of the current requested page ist unpublished, and then show 404. But not tested really, just a example.

  • Like 1
  • Thanks 1

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...