<div id="ajaxview">
<table>
<tr class="paging">
<th><?php echo $this->Paginator->sort('name');?></th>
</tr>
<tr>
<td><?php echo $data['Data']['name'];?></td>
</tr>
</table>
<div class="paginga">
<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
|<?php echo $this->Paginator->numbers();?>
|<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(".paginga").click(function(){
$("#ajaxview").load(this.href);
return false;
})
});
</script>
</div>
Showing posts with label CAKEPHP. Show all posts
Showing posts with label CAKEPHP. Show all posts
Wednesday, November 7, 2012
Cakephp Basic Ajax Pagination
Friday, September 28, 2012
Use session in model
CakePHP way:
Normal PHP way:
App::import(‘Component’, ‘SessionComponent’);
$session = new SessionComponent();
$auth = $session->read("Auth.user");
Normal PHP way:
$auth=$_SESSION['Auth']['user'];
Wednesday, August 29, 2012
Temporarily disable 'modified'
-set 'modified' => false
eg:
eg:
function view($id){
$this->data=$this->Item->read(null,$id);
$this->data['Item']['view']+=1;
$this->data['Item']['modified']=false;
$this->Item->save($this->data);
}
Friday, August 3, 2012
To use controller function in model
App::import('Controller', 'App');
$appController = new AppController();
$appController->constructClasses();
$appController->Session->setFlash('ACCESS DENIED');
$appController->redirect('/');
Saturday, March 3, 2012
SVN: ignore tmp folder in cakephp
when u are in the cakephp dir
$ cd app
$ svn export tmp tmp2
$ svn rm --force tmp
$ svn ci -m "remove tmp folder"
$ mv tmp2 tmp
$ svn propset svn:ignore tmp .
$ svn ci -m 'ignoring tmp folder'
$ cd app
$ svn export tmp tmp2
$ svn rm --force tmp
$ svn ci -m "remove tmp folder"
$ mv tmp2 tmp
$ svn propset svn:ignore tmp .
$ svn ci -m 'ignoring tmp folder'
Tuesday, January 10, 2012
List all Action in All Controller
function allControllerAction(){
$controllerClasses = App::objects('controller');
foreach($controllerClasses as $controller) {
if ($controller != 'App') {
App::import('Controller', $controller);
$className = $controller . 'Controller';
$actions = get_class_methods($className);
foreach($actions as $k => $v) {
if ($v{0} == '_') {
unset($actions[$k]);
}
}
$parentActions = get_class_methods('AppController');
$controllers[$controller] = array_diff($actions, $parentActions);
}
}
return $controllers;
}
}
Tuesday, December 6, 2011
import csv
controller
function import($merchant_id){
if(!empty($this->data['Product']['excel']['tmp_name'])){
$row = 1;
if (($handle = fopen($this->data['Product']['excel']['tmp_name'], "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, "^")) !== FALSE && $row<30) {
//process and save data
$product['Product']['name']=$data[0];
$product['Product']['description']=$data[2];
$product['Product']['merchant_id']=$merchant_id;
$product['Product']['price']=$data[3];
$product['Product']['weight']=$data[4];
$product['Product']['status']=1;
$this->Product->create();
$this->Product->save($product,false);
}
$row++;
}
fclose($handle);
}
}
Monday, November 7, 2011
CakePHP 2.0 bake
$ export PATH="{your cakephp directory}/lib/Cake/Console:$PATH
$ cd {your cakephp directory}
$ cake bake
$ cd {your cakephp directory}
$ cake bake
Wednesday, November 2, 2011
Relationship Type
class A extends AppModel {
var $name = 'A';
var $hasOne = array(
'E' => array(
'className' => 'E',
'conditions' => '',
'dependent' => true
)
);
var $belongsTo = array(
'D' => array(
'className' => 'D',
'foreignKey' => 'd_id'
)
);
var $hasMany = array(
'C' => array(
'className' => 'C',
'foreignKey' => 'a_id',
'conditions' =>'',
'order' => '',
'limit' => '',
'dependent'=> true
)
);
var $hasAndBelongsToMany = array(
'B' =>array(
'className' => 'B',
'joinTable' => 'as_bs',
'foreignKey' => 'a_id',
'associationForeignKey' => 'b_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
}
refer:http://book.cakephp.org/view/1040/Relationship-Types
Tuesday, October 11, 2011
share this
in view
$pubid = '';
$wtype = '';
echo $sharethis->init($pubid, $wtype);
horizontal
$sharethis->btnsInTray(array('twitter', 'facebook', 'yahoo', 'gbuzz', 'email', 'sharethis'));
vertically
echo $sharethis->btnWithCount(array('facebook', 'twitter', 'sharethis','plusone'), 'v');
refer:http://bakery.cakephp.org/articles/rightwayindia/2011/06/25/sharethis%E2%80%9D_social_media_helper
$pubid = '';
$wtype = '';
echo $sharethis->init($pubid, $wtype);
horizontal
$sharethis->btnsInTray(array('twitter', 'facebook', 'yahoo', 'gbuzz', 'email', 'sharethis'));
vertically
echo $sharethis->btnWithCount(array('facebook', 'twitter', 'sharethis','plusone'), 'v');
refer:http://bakery.cakephp.org/articles/rightwayindia/2011/06/25/sharethis%E2%80%9D_social_media_helper
Subscribe to:
Posts (Atom)