Hi,
I would like to use the method described in a thread on the forums
at http://www.silverstripe.org/customising-the-cms/show/6320?start=8#ForumContent
Here is a partial reproduction of the conclusive post in this thread:
cbolt's solution worked well for me. I made two minor edits...
PreviousPage function would fail if Children return a dataobjectset with no children. So updated the function to use Count():
function PreviousPage() {
$where = "ParentID = {$this->ParentID} AND Sort < {$this->Sort}";
$pages = DataObject::get("SiteTree", $where, "Sort DESC", "", 1);
if($pages) {
foreach($pages as $page) {
// if page has a child go to the last child page
$children = $page->AllChildren();
if ($children->Count()) {
foreach ($children as $child) {
continue;
}
return $child;
}
return $page;
}
}
Though being a beginner with SilverStripe and a rather non experienced programmer in php/msyql , my general rule of conduct is trying to understand what I am applying when coming from other more experienced people.
The trouble I have here is in understanding what the Sort field in the SiteTree database columns means. I can see, having a look at this field in the database that it may have various numerical value.
Where can I find an explanation of how to interpret these values ?
Many thanks in advance: