03/08/2012 4:56pm

PHP | Problem - Page.php


public function Find() {

$context = singleton('Course')->getCustomSearchContext();
$hiddenfield = new HiddenField("ParentID", 11, 11);

//$context->addField($hiddenfield);
$actions = new FieldSet(new FormAction('FindKursus', 'Kursus søgning'));

$form = new Form(
$this, 'Find', $context->getSearchFields(), $actions
);

$form->setFormMethod('GET');
$form->disableSecurityToken();

return $form;
}

public function FindKursus($data, $form) {
$context = singleton('Course')->getDefaultSearchContext();
$results = $this->getResults($data);

$data = array(
//'Title' => 'Kurser der matcher din søgning',
'Results' => $results,
'Find' => $form
);

return $this->customise($data)->renderWith(array('KursusPage_results', 'Page'));

}


function getResults($searchCriteria = array()) {
$start = ($this->request->getVar('start')) ? (int)$this->request->getVar('start') : 0;
$limit = 10;

//$filter = "StartDate > CURDATE()",
//$sort = "StartDate ASC",

$context = singleton('Course')->getCustomSearchContext();

$query = $context->getQuery($searchCriteria, null, array('start'=>$start,'limit'=>$limit));

//$query->where('"ParentID" = 11');

$searchCriteria['StartDate'] = date('Y-m-d');
//$searchCriteria['ID'] = 638;

//debug::show($query);
$records = $context->getResults($searchCriteria, "StartDate ASC", array('start'=>$start,'limit'=>$limit));

if($records) {
$records->setPageLimits($start, $limit, $query->unlimitedRowCount());
}

return $records;
}


Post Comment