jasonwydro
Registered
CakePHP 1.3 Auth (Authentication) Component Tutorial - Administrator LoginIn this tutorial, I will walk you through a complete simplified working Auth usage example w/ login/logout capabilities (and even a few added tricks!) to get you started on implementing Auth in your projects right away. All of the source code and sql dump for this project can be downloaded here: https://github.com/OldWest/CakePHP-1.3-Simple-Auth-Sample-Code If you ever have any questions, pleas...
CakePHP 1.3 - MEIO Image Upload / Resize & Gallery TutorialIn this tutorial, I show you a fast simple way to utilize cakePHP 1.3 and MEIO behaviors to get a simple image gallery up and running within minutes. All of the source code and sql dump for this project can be downloaded here: https://github.com/OldWest/CakePHP-1.3-MEIO-image-upload-sample-code If you ever have any questions, please feel free to ping me : )
CakePHP 1.3xx Search Form Query Plugin ( w/ MySQL ) Tutorial w/ Code ExamplesIn this tutorial, I go over all of the CakePHP code (plugin, model, controller and view) to implement the CakeDC Search Plugin v1.1 (w/ MySQL) & Sample-Search-Application (also by CakeDC).
**NOTE**As far as I understand, this plugin is only working with the CakePHP 1.3xx release (based on the CakeDC requirements).
This tutorial will get you up and running to create a valid working My...
There are no videos







39 Comments
This should be added in the model:
//enable date range searching.
public function makeRangeCondition($data, $field = null) {
if (is_array($data)) {
if (!empty($field['name'])) {
return array(date('Y-m-d H:i:s', strtotime($data[$field['name']].' 00:00:00')), date('Y-m-d H:i:s', strtotime($data[$field['name2']].' 23:59:59')));
} else {
$input = $data['range'];
}
}
}
Model:
public $filterArgs = array(
array('name' => 'first_name', 'type' => 'like', 'field' => 'Customer.first_name'),
array('name' => 'last_name', 'type' => 'like', 'field' => 'Customer.last_name'),
array('name' => 'application_num', 'type' => 'value', 'field' => 'Application.id'),
//enable date range searching.
array('name' => 'range_from', 'name2'=>'range_to', 'type' => 'expression', 'method' => 'makeRangeCondition', 'field' => 'Application.created BETWEEN ? AND ?'),
);
Controller:
public $presetVars = array( array('field' => 'first_name', 'type' => 'lookup', 'formField' => 'customer_input', 'modelField' => 'first_name', 'model' => 'Customer'),
array('field' => 'last_name', 'type' => 'lookup', 'formField' => 'customer_input', 'modelField' => 'last_name', 'model' => 'Customer'),
array('field' => 'id', 'type' => 'lookup', 'formField' => 'application_id', 'modelField' => 'id', 'model' => 'Application'),
array('field' => 'range_from', 'type' => 'lookup', 'formField' => 'range', 'modelField' => 'created', 'model' => 'Application'),
array('field' => 'range_to', 'type' => 'lookup', 'formField' => 'range', 'modelField' => 'created', 'model' => 'Application'),
);
View:
echo $this->Form->create('ApplicationsCustomer', array( 'url' => array_merge(array('action' => 'dealer_index'), $this->params['pass']) ));
echo $this->Form->input('first_name', array('div' => 'first_name'));
echo $this->Form->input('last_name', array('div' => 'first_name'));
echo $this->Form->input('application_num', array('div' => 'app_num', 'label'=>'ID'));
echo $datePicker->picker('range_from', array('div' => 'range_to', 'label'=>'To'));
echo $datePicker->picker('range_to', array('div' => 'range_to', 'label'=>'To'));
echo $this->Form->submit(__('Search', true), array('div' => 'search'));
echo $this->Form->end();
Feel free to contact us with questions.
CoventryLabs[dot]com
I apologize to everyone who has to try to read that gibberish.
I am trying to use the Search plugin to query by a date range using the created field from my model. Wondering if you have been able to use the expression type to get something similar. Any help is appreciated
Model:
public $filterArgs = array(
array('name' => 'first_name', 'type' => 'like', 'field' => 'Customer.first_name'),
array('name' => 'last_name', 'type' => 'like', 'field' => 'Customer.last_name'),
array('name' => 'application_num', 'type' => 'value', 'field' => 'Application.id'),
array('name' => 'range', 'type' => 'expression', 'method' => 'makeRangeCondition', 'field' => 'Application.created BETWEEN ? AND ?'),
);
Controller:
public $presetVars = array(
array('field' => 'first_name', 'type' => 'lookup', 'formField' => 'customer_input', 'modelField' => 'first_name', 'model' => 'Customer'),
array('field' => 'last_name', 'type' => 'lookup', 'formField' => 'customer_input', 'modelField' => 'last_name', 'model' => 'Customer'),
array('field' => 'id', 'type' => 'lookup', 'formField' => 'application_id', 'modelField' => 'id', 'model' => 'Application'),
array('field' => 'range_from', 'type' => 'lookup', 'formField' => 'range_from', 'modelField' => 'created', 'model' => 'Application'),
array('field' => 'range_to', 'type' => 'lookup', 'formField' => 'range_to', 'modelField' => 'created', 'model' => 'Application'),
); View:
echo $this->Form->input('range_from', array('div' => 'range_from', 'label'=>'From'));
echo $this->Form->input('range_to', array('div' => 'range_to', 'label'=>'To'));
Any help would be greatly appreciated.
JM