cakephp-2.0

Cakephp find all query on multiple models

依然范特西╮ 提交于 2019-12-12 18:15:13
问题 I try the following to get al the Articles That belong to MenuItem 6 and have an Article content_type of 'blog'. It does find all the articles with content_type='blog' . But I only want it to return the Article if it belongs to Menuitem 7. And now it return an empty value for MenuItem when not 7. How can I accomplish that it'll only load the articles from MenuItem 7? MenuItem has a HABTM relationship with Article code: $d=$this->Article->find('all' , array('contain' => array( 'MenuItem' =>

LdapAuth in cakephp 2.0

不想你离开。 提交于 2019-12-12 17:06:25
问题 i try to program a LdapAuthentication and i need some help. First i need to configure the "$components" in /app/Controller/ Component/AppController.php <?php class AppController extends Controller { var $components = array('Auth' => array( 'Ldap', 'authError' => 'Not allowed here', 'authenticate' => array('Form' => array( 'fields' => array( 'username' => 'username', 'password' => 'password', 'domain' => 'domain' ) ) ), 'authorize' => true, ), 'Session'); } ?> Then i create a LdapAuthorize.php

Different session timeouts for admin and users in CAKEPHP 2.0. is it possible?

自古美人都是妖i 提交于 2019-12-12 13:34:34
问题 I am using cakephp 2.0 for developing a website. Site will contain only 2 types of users. Admin and users(customers). now I need to set session time out 10 minutes for customer and 1 hour for admin. is it possible ?. My core.php file contains the line like this, Configure::write('Session', array( 'defaults' => 'php', 'cookie' => 'xyz', 'timeout' => 10, 'checkAgent' => false, )); 回答1: It is more correct you do this condition in the AppController than to change your core.php this magnitude. You

CakePHP 2.0: CakeEmail frustration

烂漫一生 提交于 2019-12-12 07:18:57
问题 In Cake 1.3, the EmailComponent did what it should do. The new Cake Email class in 2.0 turned out to be a frustration....No emails sent, No errors....vague documentation... I have tried all possible variants, tried it with my SMTP, Mail() and Gmail, nothing happens. Hereby my latest attempt: Controller snippet: //on top of page App::uses('CakeEmail', 'Network/Email'); //in method $email = new CakeEmail(); $email->template('contact_email') ->emailFormat('text') ->to('my@gmail.com') ->from(

I Want to send email from cakephp 2.x in company domain email adress

£可爱£侵袭症+ 提交于 2019-12-12 06:48:48
问题 I am not able to send mail.with below code:- if I remove $Email->config('gmail') than i am able to send email on id lke :- test@gmail.com but unable to send email on test@test-test@gmail.com below is the code i have added in AppController:- function sendEmail($email, $subject, $body){ App::uses('CakeEmail', 'Network/Email'); $Email = new CakeEmail(); $send=$Email->config('gmail')->from(array('support@test-apps.com'=>'test Apps')) ->to($email) ->subject($subject) ->emailFormat('html') ->send(

The request has been black-holed

心不动则不痛 提交于 2019-12-12 06:38:21
问题 when i am upload multiple images i found The request has been black-holed Error: The requested address '/admins/uploadimage1' was not found on this server. my contoller function public function uploadimage1() { if($this->request->is('post')) { $a=$this->data['Admins']['imgs']; print_r($a); } } view file <?php echo $this->Form->create('Admins',array('controller'=>'Admins','action'=>'uploadimage1', 'type'=>'file', 'accept-charset'=>'utf-8'));?> <table width="95%"> <tr><td><b>Image Title</b></td

How to read field in another view in cakephp 2

佐手、 提交于 2019-12-12 06:18:58
问题 i m in elements/navigation.ctp , in the navbar i put a condition if : <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-bell"> <?php //$this->loadModel("Location"); if($this->Session->read('auth.Location.status')==0): echo '<span class="glyphicon glyphicon-exclamation-sign" style="color:red;"> </span>'; ?> <?php endif;?> </i> <b class="caret"> </b> </a> <ul class="dropdown-menu alert-dropdown"> <li> <a href="#"><span class="label label-danger"

Can't delete row from beforeSave method in CakePHP 2.4+

不问归期 提交于 2019-12-12 04:57:55
问题 I cant delete in my beforeSave() method in newer version of Cake but it works with earler libs (e.g. version 2.2) Does anyone know how get it working again without altering the Cake libs? Code: public function beforeSave($options = array()) { if(!empty($this->data['Attachment']['delete']) && (int) $this->data['Attachment']['delete'] === 1) { if($this->deleteFromDb((int) $this->data['Attachment']['id'])) { $this->data['Attachment'] = array(); return true; } else { return false; } } return true

CakePHP - Pagination total count differs from actual count when using DISTINCT

吃可爱长大的小学妹 提交于 2019-12-12 04:54:37
问题 I have a find method that uses a DISTINCT clause to get results from my Model. The Controller code looks like below $options = array( 'limit' => 10, 'fields' => array( 'DISTINCT id', 'title', ), 'contain' => array( 'Dealer' => array('id'), ), 'paramType' => 'querystring' ); $this->Paginator->settings = $options; $cars = $this->Paginator->paginate('Car'); // returns 6 distinct rows The above query return 6 distinct rows and 12 total rows. So when I am displaying, the screen shows 6 distinct

CakePHP - Changing default Flash layout

老子叫甜甜 提交于 2019-12-12 04:48:02
问题 I know that I can replace the flash markup by creating something like custom_flash.ctp in Elements folder and call it like: $this->Session->setFlash('Hello', custom_flash) But how can I use custom layout when not adding the second parameter? $this->Session->setFlash('Hello') I thought I can replace the default by having a file named default.ctp inside Elements folder. But I can't. I want to keep the code as short as possible. That's why I'm looking a way to do this Any solution? Thanks 回答1: