Hi,
Thanks for your comment below is my Page.php code, the function that cause error is within LatestNews().
-----------------------------------------------------------------------------------
<?php
class Page extends SiteTree {
static $icon = "themes/tonlesap/images/sitetree/page";
public static $db = array(
);
public static $has_one = array(
'IntroPhoto' => 'BetterImage'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Photo", new ImageField("IntroPhoto", "Featured Photo"));
return $fields;
}
function LatestFeatures() {
$pid = DataObject::get_one("Page", "ParentID= $this->ID");
return ($pid) ? DataObject::get("FeaturePage", "ParentID = $pid->ID", "", "", "") : false;
}
function LatestAnnouncements() {
return DataObject::get(
"Announcement", "",
"LastEdited DESC", "", ""
);
}
function LatestNews() {
$nid = DataObject::get_one("NewsPage", "ParentID = $this->ID");
if ($nid == '0') {
$nid = DataObject::get_one("NewsPage", "ParentID = $this->ParentID");
}
return ($nid)? DataObject::get(
"NewsItem", "NewsPageID = $nid->ID",
"LastEdited DESC", "", "5"
) : false;
}
}
public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = true) {
$page = $this;
$parts = array();
$i = 0;
while (
$page
&& (!$maxDepth || sizeof($parts) < $maxDepth)
&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
) {
if ($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
if ($page->URLSegment == 'home')
$hasHome = true;
if (($page->ID == $this->ID) || $unlinked) {
$parts[] = ("<li class=\"current\">" . Convert::raw2xml($page->MenuTitle) . "</li>" );
} else {
$parts[] = ("<li><a href=\"" . $page->Link() . "\">" . Convert::raw2xml($page->MenuTitle) . "</a>");
}
}
$page = $page->Parent;
}
return implode(self::$breadcrumbs_delimiter, array_reverse($parts));
}
}
class Page_Controller extends ContentController {
function mynews() {
$myalatest = DataObject::get('NewsItem');
return $myalatest->renderWith('newsfilexml');
}
public static $allowed_actions = array(
'newsfilexml'
);
public function init() {
parent::init();
//Set our theme's root folder
$themeFolder = $this->ThemeDir();
//Add all the files to combine into an array
$CSSFiles = array(
$themeFolder . '/css/layout.css',
$themeFolder . '/css/typography.css',
$themeFolder . '/css/form.css',
);
//Set the folder to inside our theme so that relative css image paths work
Requirements::set_combined_files_folder($themeFolder . 'combinedfiles');
//Combine!
Requirements::process_combined_files("main.css", $CSSFiles);
Requirements::javascript('themes/tonlesap/scripts/jquery.min.js');
Requirements::javascript('themes/tonlesap/scripts/corner.js');
}
}
Thanks for your time and comment.
Bunheng