cakephp-2.0

CakePHP 2.1 Ajax validation errors

旧时模样 提交于 2019-12-06 15:55:01
问题 I'm trying to get validation errors with Ajax and jQuery working in CakePHP 2.1 for a contact form. On blur of the name field a js function is called: $(document).ready(function(){ $('#name').blur(function(){ $.post( '/Cake_ajax/Contacts/validate_form', { field: $(this).attr('id'), value: $(this).val() }, handleNameValidation ); }); function handleNameValidation(error){ if(error.length > 0){ if($('#name-notEmpty').length == 0){ $('#name').after($('<div id="name-notEmpty" class="error-message"

CakePHP - Include class from a directory outside the app directory

安稳与你 提交于 2019-12-06 14:15:30
I am trying to include a miscellaneous library class from outside my app (it gets used by different apps). My app is located at: /var/www/websites/my_website/app/ And the class is located at: /var/www/websites/libs/CakePHP/MyClass.php In my bootstrap I'm struggling to figure out how to add the path for loading the classes from that directory: App::build(array('Lib' => array('/var/www/websites/lib/'))); App::uses('MyClass', 'CakePHP'); $myClass = new MyClass(); Loading shouldn't be done in your bootstrap, but in your AppController 's beforeFilter method instead. Also, there is a reserved place

Multiple databases with CakePHP - setting database name from Controller to Model

雨燕双飞 提交于 2019-12-06 13:50:32
问题 My problem is identical to that described in this question - which is that I have a central database to host user login information while each user has their own transactional database which they will utilize for other operations besides login. There is no way of knowing which database the user will operate on until login is complete so it is not possible to use the database configuration file. The solution provided with this question work perfectly except for one (major) problem. It doesn't

Ajax pagination with filters in cakephp

风格不统一 提交于 2019-12-06 13:32:02
问题 Can anybody give a best example of ajax pagination in cakephp 2.x. This should include data filtering also. I have read cakephp manual but could not understand much. 回答1: After a long search and work, i have developed a solution which is as follows: Client Side: Fist of all create a form with all filtering options. Submit the form using ajax. Use Post method to submit the form. Submit the form using serialize method. Server Side: All filter form data will be available in $this->request->data.

CakePHP: How to use Containable for nested HABTM models

有些话、适合烂在心里 提交于 2019-12-06 13:06:12
I'm trying to use Containable to return a model with several of its associated models (and those arrays of data). The models deal with test results. Here are the models: Models: Question : has and belongs to many Category Category : has and belongs to many Question Attempt : has many AttemptedQuestions AttemptedQuestion : belongs to Question I want to return an Attempt with all of it's AttemptedQuestions and their corresponding Quesions + Category So basically, the relationships map like this: Attempt => AttemptedQuestion(s) => Question => Category I suspect that because of the HABTM

sending data via ajax in Cakephp

99封情书 提交于 2019-12-06 11:59:49
i am new to cakephp and trying to send data from ajax to my controller action.. i have a popup model in which there is a input box ..i want to grab that value and send to controller without page refresh here is my code .. <a class="button anthracite-gradient" onclick="openPrompt()">submit </a> my javascript function openPrompt() { var cancelled = true; $.modal.prompt('Please enter a value:', function(value) { $.ajax({ type:"POST", url:"/cakephp/controller/action/", success : function(data) { alert(value); //value right now is in this variable ... i want to send this variable value to the

how to pull posts from wordpress to other non-wordpress site on different hosting?

我的梦境 提交于 2019-12-06 11:18:41
问题 How can I pull the posts of one blogger(written on his wordpress blog) to my site without installing the wordpress on my site? What are requirements and limitations of doing that? 回答1: There are a couple ways to use wordpress as a CMS only, without actually using it as your site or to expose content for use on another site. RSS feeds as noted in another answer is good for read-only access to posts. To interact with content you'll need another solution. You can enable XML-RPC in wordpress and

CakePHP find joined records with conditions on each table

杀马特。学长 韩版系。学妹 提交于 2019-12-06 10:41:06
I want to see all the records from a join, setting a WHERE condition on each side of the join. For example, I have LOAN and BORROWER (joined on borrower.id = loan.borrower_id ). I want the records where LOAN.field = 123 and BORROWER.field = 'abc' . The answers here ( this one , for example) seem to say that I should use Containable. I tried that. Here's my code: $stuff = $this->Borrower->find('all', array( 'conditions' => array( 'Borrower.email LIKE' => $this->request->data['email'] // 'abc' ), 'contain'=>array( 'Loan' => array( 'conditions' => array('Loan.id' => $this->request->data[

How to insert multiple records

 ̄綄美尐妖づ 提交于 2019-12-06 10:34:21
I am a new cake php developer.I am trying to insert multiple record but i cant.My table Structure is given below: Table Name : agents ============================================== id | Contact | Name | email_add | Address ============================================== Controller Code : public function send_money() { $this->layout='agent'; $this->Agent->create(); $this->Agent->set($this->data); if(empty($this->data) == false) { if($this->Agent->save($this->data)) { $this->Session->setFlash('Information Added Successfully.'); $this->redirect('send_money'); } } else { $this->set('errors', $this-

Auth for static page cakephp [closed]

落花浮王杯 提交于 2019-12-06 10:05:38
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 5 years ago . I am new in cakephp.. I am making a website , there no users hierarchy , there is only the admin and public users. I want to disallow the public users from entering a certain static page. of course the page is located in view/pages , so its view/pages/adminPanel.ctp . please specify where I should include the code you will give. Thank you in advance here's my display function