Programatically add a new page without publishing a version
Permalink 2 users found helpful
When I use $newPage = $parentPage->add($pt,$data); to create a new page, a version of the page is published immediately.
Is there a method to create/add a new page so that the new page is not published?
Thanks,
Marcus.
Is there a method to create/add a new page so that the new page is not published?
Thanks,
Marcus.
Job,
Thanks for the reply.
It must be possible because if I use the add page button on the tool bar of a page, the new page does create a new unpublished version, just like I want.
Thanks,
Marcus
Thanks for the reply.
It must be possible because if I use the add page button on the tool bar of a page, the new page does create a new unpublished version, just like I want.
Thanks,
Marcus
Scrap that. It's possible...
Here you go, utilise the "cvIsApproved" in your $data array like so ...
Don't forget to mark it as the answer if it helps!
Job.
Here you go, utilise the "cvIsApproved" in your $data array like so ...
Don't forget to mark it as the answer if it helps!
Job.
Awesome Job.
Thanks so much for tracking that down for me.
It works and so simple.
Thanks so much for tracking that down for me.
It works and so simple.
Glad I could help mrowell :-)!
Do you think it's also possible to set Attributes with this method? Or does it require something a little different?
$data = array( 'name' => "sample2", 'cHandle' => "sample2handle", 'cDescription' => "Add page test.", 'cvIsApproved'=> false, 'attribute_name'=> 'stuff' );
Yes.
For others looking into this issue, Remo confirmed this is possible at http://www.concrete5.org/community/forums/customizing_c5/add-page-p...
For others looking into this issue, Remo confirmed this is possible at http://www.concrete5.org/community/forums/customizing_c5/add-page-p...
As in, in my News System, when people where making edits within my GUI, their updates weren't being automatically approved unless I called:
As far as I can see, throughout the forum people have asked time and time again whether its possible through GUI to which everyone has responded no, so I would imagine thats the case for programatically as well.
I can't see anything in the CollectionVersion class (https://github.com/concrete5/concrete5/blob/5.5.2-devel/web/concrete/models/collection_version.php#L22).
It might be worth looking into changing permissions programatically so that Guests can't read the page and added the exclude from nav attribute.
Let me know how you go on.
If this helps, be sure to mark it as the answer.
Job.