cakephp-2.4

Different levels of URL with CakePHP routes

杀马特。学长 韩版系。学妹 提交于 2019-12-08 03:15:33
问题 I have a site that needs to allow multiple URL structures. For example: www.examplesite.com/people/add // <-- example company www.otherexample.com/xyz/people/add // <-- "xyz" company (not location based) www.otherexample.com/florida/abc/people/add //<-- "abc" company (location based) Each URL should be able to detect which company it is based on the URL. So far, I've been able to parse out the URL just fine to determine which company it is, but how to I add these extra /florida/abc/ parts to

Fatal error: Cannot redeclare class NewsModel

你。 提交于 2019-12-08 01:06:30
问题 the problem is a bit strange, I'm fighting with it since 2 days and before I post it as a bug just wanted to make sure this is not my mistake. I have a clean CakePHP copy, I have a DB which is setup and Cake can connect to my DB with no problem. in my DB I have a table named "news", and I have a controller with the following code: <?php class UsersController extends AppController { public $uses = array('News'); public function news(){ $news = $this->News->find('all'); var_dump($news); die; }

Hashing password when adding new user

℡╲_俬逩灬. 提交于 2019-12-06 15:14:53
CakePHP 2.4 While adding a new user I must hash passwords before storing it in the Database. To do so I did: //UsersController public $helpers = array('Html', 'Form'); public $components = array( 'Session', 'Auth' => array( 'loginRedirect' => array('controller' => 'users', 'action' => 'home', 'home'), 'logoutRedirect' => array('controller' => 'users', 'action' => 'logout') ) ); public function add(){ if($this->request->is('post')){ $this->User->create(); if($this->User->save($this->request->data)){ $this->Session->setFlash('Saved!'); } } } //UserModel public function beforeSave(){ if(isset(

Different levels of URL with CakePHP routes

老子叫甜甜 提交于 2019-12-06 10:48:44
I have a site that needs to allow multiple URL structures. For example: www.examplesite.com/people/add // <-- example company www.otherexample.com/xyz/people/add // <-- "xyz" company (not location based) www.otherexample.com/florida/abc/people/add //<-- "abc" company (location based) Each URL should be able to detect which company it is based on the URL. So far, I've been able to parse out the URL just fine to determine which company it is, but how to I add these extra /florida/abc/ parts to the routes to allow the rest of the app to work? I've tried a number of things including setting a

Fatal error: Cannot redeclare class NewsModel

放肆的年华 提交于 2019-12-06 08:17:04
the problem is a bit strange, I'm fighting with it since 2 days and before I post it as a bug just wanted to make sure this is not my mistake. I have a clean CakePHP copy, I have a DB which is setup and Cake can connect to my DB with no problem. in my DB I have a table named "news", and I have a controller with the following code: <?php class UsersController extends AppController { public $uses = array('News'); public function news(){ $news = $this->News->find('all'); var_dump($news); die; } } as long as I dont create the model file for my table, this query runs successfully, but as soon as I

how to implement JsonP in cakephp 2.4

喜欢而已 提交于 2019-12-04 17:00:53
I have just upgraded to cakephp 2.4.1 as it now supports JsonP. I was previously getting an a missing callback error in my ajax cross domain code. However the documentation does not mention any additional steps need to implement this so I would have thought that it should wold but i get the same error as before. Do I need an extra piece of code to send the callbck back? My Controller public function api($mem_id = null) { $options = array( 'fields' => array('Member.total_points'), 'conditions' => array('Member.member_no' => $mem_id), 'recursive' => -1 ); $members = $this->Member->find('first',

Saving Multiple Select in input

点点圈 提交于 2019-12-02 15:10:23
问题 I have model for user(id,name) section(id,name) section_users(id,user_id,section_id) The admin adds all the users and sections separately. Once theses are added I want the admin to selects the section and add all the users in it in section_users I have a select input with multiple set to true. How do i save this data the cakephp way along with validation. <?php echo $this->Form->input("section_id"); ?> <?php echo $this->Form->input("user_id", array('multiple'=>'checkbox')); ?> This generates

Saving Multiple Select in input

白昼怎懂夜的黑 提交于 2019-12-02 07:40:54
I have model for user(id,name) section(id,name) section_users(id,user_id,section_id) The admin adds all the users and sections separately. Once theses are added I want the admin to selects the section and add all the users in it in section_users I have a select input with multiple set to true. How do i save this data the cakephp way along with validation. <?php echo $this->Form->input("section_id"); ?> <?php echo $this->Form->input("user_id", array('multiple'=>'checkbox')); ?> This generates Array ( [section_id] => 1 [user_id] => Array ( [0] => 3 [1] => 4 ) ) I know i can loop and convert to

CakePHP TwigView Plugin Missing View Error

…衆ロ難τιáo~ 提交于 2019-12-01 14:37:37
I am using CakePHP 2.4.2 and this plugin by predominant. I want to use TwigView with CakePHP and found that the plugin above is compatible with CakePHP 2.0. Followed all the installation steps, however, getting the Missing View error while executing the script. My AppController.php <?php App::uses('Controller', 'Controller'); class AppController extends Controller { public $viewClass = 'TwigView.Twig'; } The view's extention is .tpl , however, even after adding the Plugin it is still looking for .ctp extention. I have also loaded the plugin in bootstrap.php using CakePlugin::load('TwigView');

CakePHP - How do I implement blowfish hashing for passwords?

送分小仙女□ 提交于 2019-11-29 07:37:33
Struggling to find answers to a few basic questions about using Blowfish in Cake 2.4. AppController.php public $components = array( 'Auth' => array( 'authenticate' => array( 'Form' => array( 'fields' => array( 'username' => 'email' ), 'passwordHasher' => 'Blowfish' ) ) ), 'Cookie', 'Session' ); What now? How do I log in? UsersController.php public function login() { if (!empty($this->request->data)) { if ($this->Auth->login()) { $this->redirect($this->Auth->redirectUrl()); } } } What do I need to add to this? I'm getting the following error if I try to log in: Warning (512): Invalid salt: for