api/commentary/
/api/commentary/235
$c = $this->getPrimaryKeyCriteria($id); $this->object = $this->modx->getObject($this->classKey,$c);
This question has been answered by lightweight30. See the first response.
$url = $_SERVER['REQUEST_URI']; $hasNumber = preg_match('#(\d+)$#', $string, $matches); if ($hasNumber) { $fixtureID = $matches[1]; $c = array('fixtureID' => $fixtureID); } else { /* No number at end of string do something else */ }
/** * Route GET requests * @return array */ public function get() { $pk = $this->getProperty($this->primaryKeyField); if (empty($pk)) { Throw new Exception('Not found', 404); return false; } return $this->getList($pk); }
/** * Abstract method for routing GET requests without a primary key passed. Must be defined in your derivative * controller. Handles fetching of collections of objects. * * @abstract * @return array */ public function getList($id) { $this->getProperties(); $c = $this->modx->newQuery($this->classKey); $c->where(array('fixtureID' => $id)); $c = $this->addSearchQuery($c); $c = $this->prepareListQueryBeforeCount($c);