Problem:
On a Syntax site, You have a uri like
http://www.mysite.com/content/news/detail/5678/ and you need to extract
the number to use as your record id:
you could do it the wrong way in bare php:
$uri = explode('/',$_SERVER['REQUEST_URI']);
$id = $uri[4];
if(preg_match("/\?/",$id))
{
$elements = explode('?',$id);
$id = $elements[0];
}
or you could do it using the more readable/maintainable Syntax way:
if ($Request->getVar('id')) {
$id = $Request->getVar('id');
}
else
{
// look for it in the Request trailpoint (assumes it's 3rd element
// in path since content/ doesn't count and index starts at o );
$id = $Request->getPathElement( 2 );
if ( !is_numeric( $id ) || empty( $id) )
{
trigger_error( 'Non-numeric or missing record id.', E_USER_ERROR);
}
}
Oscar