I have a DataObject attached to the Page Controller and a Custom Function to check it Exists in the Template, however it looks like Extra Dataobjects don't get attached to the CMS login pages and as such Generates an Error for a Malformed SQL query. Whats the BEst way to resolve this?
This is the Query in my Page Controller
function LifeStyleShot() {
$result = DataObject::get("ExtraPageImages","Category = 'Lifestyle' AND PageID=".$this->ID);
if($result) {
return $result;
}
else {
$backup = DataObject::get("ExtraPageImages","Category = 'Lifestyle' AND PageID=".$this->ParentID);
if($backup) {
return $backup;
}
else {
return false;
}
}
}
The Template Code on the Page.ss looks like this:
<% if LifeStyleShot %>
<% control LifeStyleShot %>
<img id="lifestyle" src="$Attachment.URL" width="960" height="401" alt="lifestle" />
<% end_control %>
<% else %>
<img id="lifestyle" src="/themes/loverschoice/img/lifestyle2.jpg" width="960" height="401" alt="lifestle" />
<% end_if %>