Reputation: 291
I have the following layout:
mypage.ss
$CreateString
<% loop $LatestString %>
<div>$StringVar</div>
<% end_loop>
mypage.php
class MyPage extends Page {
private static $db = array(
'StringVar' => 'Varchar'
);
}
class MyPage_Controller extends Page_Controller {
public function CreateString() {
$varS = MyPage::create(array('StringVar' => 'Jonh Davies'));
$varS = MyPage::write();
return $varS;
}
public function LatestString() {
return MyPage::get()
->sort('Created', 'DESC')
->limit(1);
}
}
The thing is nothing is created and there is now output from the controller. No record created, and no output.
Upvotes: 1
Views: 87
Reputation: 619
In the above example MyPage is not published. Your CreateString method should look more like:
$varS = MyPage::create(...);
$varS->write();
$varS->publish('Stage', 'Live');
return $varS;
I'm not even sure what "MyPage::write" will do but it probably is not even saving the record in the staging table to begin with. I'm a little surprised that's not generating an error.
Upvotes: 2