Skip to main content

Posts

Showing posts with the label CakePHP

CakePHP: JS and CSS files are not loading

When I faced this issue with one of my projects and searched over the internet, out of the suggested solutions, nothing worked. Anyhow, with some luck and R&D, I was able to fix this issue. Hence, sharing it with a larger group to help others who are or will face the same issue as mine.  If apache is your web server and your CakePHP project is in /var/www/html/ folder then please make sure that  AllowOverride All enabled for /var/www/html To enable AllowOverride All for /var/www/html following is an example for  /etc/apache2/sites-available/ 000-default.conf <VirtualHost *:80 >         # The ServerName directive sets the request scheme, hostname and port that         # the server uses to identify itself. This is used when creating         # redirection URLs. In the context of virtual hosts, the ServerName         # specifies what hostname mu...

CakePHP TinyMCE Validation Problem

In development world, daily we face lot of problems, some are big while some are minor. Sometimes it takes a lot of time to fix small one than bigger ones. Similar to this, today I faced a small issue with TinyMCE in CakePHP. It was to set an attribute and to figure it out itself took couple of hours of mine. Then I decided to share it with my readers, thinking that it may save those couple of hours of someone else at some point of time. Problem : TinyMCE notempty validation was not working fine and it was showing following message on console. An invalid form control with name='page [description]' is not focusable Solution :  Set required attribute to be false in view file. For example : <div>                 <div class="umstyle3"><?php echo __('Page Description');?></div>              ...

CakePHP code not working on Production Server?

Today when I was preparing myself for tomorrow’s project demo uploaded whole project code on production server. But something strange happened; code was not working as expected. But same code was working fine on my local system. Just noticed that no validation was working and database related functions were also not working fine. Searched over internet and stackoverflow but didn’t answer that could rectify my problem. I thought may be it happened due to Auth component I used. But again if it’s working on local system then it should also work on production server. Keep searching and finally got a blog where I got the proper answer. I did a mistake actually so I was the only culprit. For model names I used different nomenclature. For users table I used User.php as model file name instead of user.php and so on. When I did those changes everything worked fine. So please keep it mind that model file name should be e.g user.php (all small characters) format.  Thanks!!!!!!!!! Enjoy P...

CakePHP Complex Find Conditions

Today we are going to discuss over complex find conditions using multiple 'AND' and 'OR' operators.   I was to write a CakePHP find condition for following query : Select * from Quarter where Quarter.status = 1 AND ((Quarter.start_date >= '2012-04-01' AND Quarter.end_date <= '2012-06-30') OR (Quarter.start_date >= '2012-07-01' AND Quarter.end_date <= '2012-09-30')) ; It's not that typical but typical enough to understand the concept. First I wrote this query : $conditions = array(                 'conditions' => array(                                 'AND' => array(                         ...