3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1173 Views |
-
How to create & publish a Page with the ORM

8 December 2009 at 9:47am Last edited: 8 December 2009 9:48am
Hi all,
i attempt to create & publish an Page with the ORM till 5 hours now. The Problem i see, is the versioning. I can't find a Dokumentation of this SS Part. Now, i need help.
My Code Snippet :
Referenz extends Page { ... }
.....
ReferenzHolder extends Page {
.....$referenz = new Referenz();
$referenz->ParentID = $this->dataRecord->ID; // ID of ReferenzHolder
$referenz->Title = $data['Title'];
$referenz->Status = "Published"
$referenz->write();
$referenz->publish('Stage', 'Live');
....
}SS creates two Records in SiteTree. One ReferenzHolder and one Referenz. My Questions :
1. Why SS creates an ReferenzHolder?
2. Why SS creates the two Records with the Status Attribute "New Page" instead of "Published"?If anyone has a link to some Documentions about creating & publishing Pages with ORM, i become relieved.
Regards,
Stefan
-
Re: How to create & publish a Page with the ORM

28 December 2009 at 2:22am
Stefan,
I'm not sure about #1. I suspect we may need to see more of your code to figure out why a ReferenzHolder is being created. I think I was having a similar problem to your #2, though, with code that looked pretty similar. Here's what fixed it for me:
// change this:
$referenz->write();// to this:
$referenz->writeToStage('Stage');Because I was running my code on the frontend side, which was currently in Live mode, the write() call was saving to the live table and then the publish from stage to live was actually overwriting it. This way, it correctly saves to the Stage table, then publishes from Stage to Live.
Hope that helps,
Mark
| 1173 Views | ||
|
Page:
1
|
Go to Top |
