stuartsa Posted May 10, 2019 Share Posted May 10, 2019 My name is Stuart Simon. I'm new to the world of ProcessWire, and I was enticed by its ability to act as a mock database frontend for my needs. I'm trying to create a REST API (using the REST API module) for my site to ease the data migration, and I want to understand why there is no Page::publish() method. I am using the Blank profile and have not edited config.php at all. Does calling the Page::save() method automatically try to publish the page if the Page::addStatus() method has NOT been called? Does calling the Pages::add() method automatically call the Page::save() method on the created page? Thank you! Link to comment Share on other sites More sharing options...
Robin S Posted May 11, 2019 Share Posted May 11, 2019 Hi @stuartsa, welcome to the PW forums. ? On 5/11/2019 at 5:52 AM, stuartsa said: Does calling the Page::save() method automatically try to publish the page if the Page::addStatus() method has NOT been called? Publishing a new page that is created via the API is not an extra action because pages are published by default. Or more accurately, they are "not unpublished" by default, because being unpublished is an extra status that you may add to a page but is not present by default. When a page is created in the admin via ProcessPageAdd it gets the unpublished status added because the expectation is that the user probably wants to populate some fields in a following step before the page becomes accessible on the front-end, and also because new pages can be added by roles with more restricted permissions than superuser. But when you add pages via the API then you are an unrestricted superuser and so it is up to you to populate the page fields and set page statuses as you see fit. On 5/11/2019 at 5:52 AM, stuartsa said: Does calling the Pages::add() method automatically call the Page::save() method on the created page? Yes. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now