Jump to content

Recommended Posts

Posted

On page A I'm trying to get some fields data from page B, which I need to be hidden/undiscoverable. I'm using `$pages->get` method, but as soon as I make page B hidden/unpub, page A returns error.

How can I workaround this?

Thanks!

Posted (edited)

Hi. Have you tried to add include=all or include=hidden as parameter or via the options array to the get or find API calls? See API overview for details: https://processwire.com/api/ref/pages/find/

From the API doc page: 

  • include (string): Optional inclusion mode of 'hidden', 'unpublished' or 'all'. (default=none). Typically you would specify this directly in the selector string, so the option is mainly useful if your first argument is not a string.

Cheers cwsoft

Edited by cwsoft
Posted
pages(1040)->title;
$pages->get(1040)->title;
$pages->findOne("id=1040, include=hidden")->title();

Here's an example dumping the title property and the status of my Demo, hidden page.

image.thumb.png.f067e33169c525176bb298951e6e1850.png

Posted

I read on the documentation about `find`:

Quote

This is functionally similar to the get() method except that its default behavior is to filter for access control and hidden/unpublished/etc. states

So `get` should fetch also unpublished pages. Still not working... I'm using it through the `child` method, I guess `child` inherits `get` functionalities right?

Posted

being 1033 the page with the children you want to get:
 

//Given than child only returns a single page, you can use sort,to for example get the newest child of 1033.
$pages->get(1033)->child("sort=-created, include=hidden");

 

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