Hi all,
I've currently got a basic member profiles system running, and I'm expanding it to respond to SEO friendly URLS e.g. ../profile/show/george instead of ../profile/show/1
"/profile" is the page, "/show" is the action and "/1" is obviously the ID.
The code for function show is:
function show()
{
if($Member = $this->getMemberByName()) //Use getMemberByID() for unfriendly URLS
{
$Data = array(
'Member' => $Member
);
return $this->Customise($Data);
}
else
{
return $this->httpError(404, 'Profile not be found');
}
}
And the function for getMemberByID is:
public function getMemberByID()
{
$Params = $this->getURLParams();
if(is_numeric($Params['ID']) && $Member = DataObject::get_by_id('Member', (int)$Params['ID']))
{
return $Member;
}
}
So I adapted it to filter the DataObject::get by a different field in the Member table, "URLSegment", which was applied through a separate DataObjectDecorator class.
My code for getMemberByName is:
function getMemberByName() {
$Params = $this->getURLParams();
if($Params && $Member = DataObject::get('Member', "`URLSegment` = '{$Params}'" ))
{
return $Member;
}
}
But it results in a 404.
I must be missing something in the DataObject query - any ideas?
Thanks in advance for help.