Hi All,
I am trying to access an objects parent parent. For example. I have a homepage that has a featured article. The article is in a structure of Category >> Sub Cat >> Article. So I can access the parent of the article to get the sub category - $FeaturedArticle.Parent.Link
When I try $FeaturedArticle.Parent.Parent.Link though this will then simply return an error stating the forTemplate method is not available for category to render. Because of this I added the forTemplate method but then nothing returns at all when I call it. No errors, nothing. My forTemplate function is below, any idea when I then call $FeaturedArticle.Parent.Parent nothing displays on my .ss template? Also does anyone know a better way to access this data from the $FeaturedArticle variable that I have.
function forTemplate() {
$whereStatement = "CategoryPage_Live.ID = " . $this->ID; // Select the current category
$orderBy = null;
$limit = null;
$join = null;
//$whereStatement = "ParentID = ".$this->ParentID." AND ID <> ".$this->ID;
$cat = DataObject::get("CategoryPage", $whereStatement, $orderBy, $join, $limit);
$string = '<a href="'.$cat->Link.'">'.$cat->Title.'</a>';
return $string;
}