cakephp-2.0

Cakephp foreach condition

*爱你&永不变心* 提交于 2020-01-11 13:01:12
问题 i would have to show the table of reservation of 3 biens it should show me 3 line of 3 reservation but it show me just one line in the controllers public function index_hote() { $this->Reservation->recursive = 1; $this->loadModel("BiensPersonne"); if($this->Session->read('Auth.User.0.Personne.id')){ $options = $this->BiensPersonne->findByPersonneId($this->Session- >read('Auth.User.0.Personne.id')); $this->loadModel("Personne"); $biens=$this->Personne->findById( $options['BiensPersonne'][

Last x blog entries - but only once per user

冷暖自知 提交于 2020-01-10 03:24:49
问题 I would like to display a box with the last x (say 5) blog entries. But I would like to avoid that a very active user is listed twice. My tryout boils down to: $stats['blog'] = $this->User->Blog->find('all', array( 'order'=>array('Blog.published' => 'DESC'), 'conditions' => array('Blog.status' => 1), 'contain' => array('User.username'), 'group' => array('User.id'), 'limit' => 5, )); But - of course - it groups too soon without the chance of sorting it first. The resulting sql often loses the

cakephp remove controller name from url

爷,独闯天下 提交于 2020-01-07 07:36:44
问题 i am working on a cakephp 2.x .. right now i have a function called forgetpassword and resetpassword in my userscontroller .. i am sending an email to a user.. i am sending a url like this ..this code is written in the forgetpassword function $url = Router::url( array('controller'=>'users','action'=>'resetpassword'), true ).'/'.$key.'#'.$hash; and i receive this url in my inbox like this https://www.myweb.com/resetpassword/y2273727372jhgdfjjd2434dff#23232323 when i click the url which is on

CakePHP hiding action name in URL, while passing arguments

南楼画角 提交于 2020-01-07 02:34:45
问题 I have such a structure: example.com / MyController / index / MyGoodPage / maximum/ example.com / MyController / index / MyBestPage / optimum/ example.com / MyController / index / MyFancyPage / lowprice/ But I don't want my visitors to see "index" word, because it doesn't give any more information to him/her. I need my URLs like this: example.com / MyController / MyGoodPage / maximum/ example.com / MyController / MyBestPage / optimum/ example.com / MyController / MyFancyPage / lowprice/ But

Containable and deep associated data

走远了吗. 提交于 2020-01-06 19:12:31
问题 document has many document_item document_item has many document_item_description and belongs to document document_item_description has one document_item I'm trying to get a document with all document_items and all associated document_item_descriptions for the associated document_items Is there a way to do this? Right now all I can get are document_items but can't get down to the third level. class Document extends AppModel { public $hasMany = array( 'Document_item' => array( 'className' =>

Containable and deep associated data

穿精又带淫゛_ 提交于 2020-01-06 19:11:18
问题 document has many document_item document_item has many document_item_description and belongs to document document_item_description has one document_item I'm trying to get a document with all document_items and all associated document_item_descriptions for the associated document_items Is there a way to do this? Right now all I can get are document_items but can't get down to the third level. class Document extends AppModel { public $hasMany = array( 'Document_item' => array( 'className' =>

cakephp $this->data loses a LOT of its data array after form submit

我怕爱的太早我们不能终老 提交于 2020-01-06 18:12:45
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

cakephp $this->data loses a LOT of its data array after form submit

一笑奈何 提交于 2020-01-06 18:12:18
问题 I have a manage_photos page whose $this->data contains a great deal of information about its Unit. I have a form which makes the appropriate changes in the database. However, upon submission of the form, $this->data (as seen when using pr($this->data)) loses MOST of its array data once the page refreshes. Here is the form code in my view: echo $this->Form->create('Unit', array( 'action' => 'manage_photos', 'type' => 'file', 'inputDefaults' => array( 'label' => false, 'div' => false ) ) );

Can't change 'userModel' using AuthComponent in CakePHP

我的梦境 提交于 2020-01-06 14:58:13
问题 I'va been trying to change the 'userModel' from the default 'user' to 'usuario'. I'va done this before in CakePHP 1.3 but I can't get it to work using the lastest version. Here's my code (AppController.php): App::uses('Controller', 'Controller'); class AppController extends Controller { public $components = array( 'Auth' => array( 'loginError' => "Nombre de usuario o contraseña incorrectos.", 'authError' => "Debes ingresar con tu cuenta de usuario.", 'loginRedirect' => array('controller' =>

Converting named parameters to GET parameters for pagination at CakePHP 2.2

百般思念 提交于 2020-01-06 08:48:13
问题 I am trying to convert named parameters to GET parameters for pagination at CakePHP 2.2 following the instructions given in the documentation but it is not working. Instead of this: http://localhost/cake/posts/yourPosts/page:2?url=posts%2FyourPosts I want this: http://localhost/cake/posts/yourPosts/?page=2&url=posts%2FyourPosts The thing is, when i submit a form using GET method, i don't want to retain the current page, and currently, it is doing it by default because it is not a normal param