Hi,
It's been a while since I've worked with SilverStripe (due to employment and time constraints) but now I'm jumping back in as it is something I truly enjoy. I started working with an old install running SilverStripe 2.4 and all is going well (will upgrade to 3.0 in the next project but that will be next week). One issue I am struggling to resolve is pagination on children. I have the search function working and pagination on a query works fine. But I am unsure of how to implement it using the following code:
AccommodationPage.php
---------------------------
<?php
class AccommodationPage extends Page {
//db fields
static $db = array (
'Name' => 'Varchar(255)',
'Website' => 'Varchar(100)',
'Email' => 'Varchar(100)'
);
static $has_one = array(
'Photo' => 'Image'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Images', new ImageField('Photo'));
$fields->addFieldToTab('Root.Content.Main', new TextField('Name'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Website'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new EmailField('Email'), 'Content');
return $fields;
}
}
class AccommodationPage_Controller extends Page_Controller {
//tried adding the below and using a control on AccommodationPageList but this outputs nothing
public function AccommodationPageList($limit=10){
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
$list = DataObject::get("AccommodationPage", "Website", "$start", "$limit");
return $list;
}
}
?>
AccommodationHolder.php
---------------------------
<?php
class AccommodationHolder extends Page
{
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('AccommodationPage');
}
class AccommodationHolder_Controller extends Page_Controller {
}
?>
AccommodationPage.ss
-----------------------
<div id="main">
<% include Breadcrumbs %>
$Content
</div>
<div id="sidebar">
<% include Navigation2 %>
</div>
AccommodationHolder.ss
------------------------------
<div id="accommodation">
<% include Breadcrumbs %>
$Content
<% control Children %>
<div class="accommodation-wrapper">
<div class="header-summary">
<h4 style="display:inline">$Name</h4>
<span class="website">
<a href="$Website">Website</a>
</span>
<span class="email">
<a href="mailto: $Email">Email</a>
</span>
</div>
<div class="photo">$Photo.SetWidth(150)</div>
<div class="description">
$Content
</div>
</div>
<% end_control %>
</div>
<br />
<% control AccommodationPageList %>
<p>$Website</p>
<% end_control %>
******************************
So any ideas on how to get pagination on the accommodation list? I think I need to do a separate query and simply call that in the control.
TIA and all help appreciated.
//Mark