Skip to main content

Posts

Check All by jQuery

Check All by jQuery Method 1:  $(document).ready(function() {     $('#selectAll').click(function(event) {         if(this.checked) { // check select status             $('.checkbox1').each(function() {                 this.checked = true;  //select all checkboxes with class "checkbox1"                         });         }else{             $('.checkbox1').each(function() {                 this.checked = false; //deselect all checkboxes with class "checkbox1"                                 });               }     });   }); Html <div> <input type="checkbox" id="selectAll"...

Sort Table by jquery

1.  Sort table first column by jQuery Create a function sortTable. Pass table id & order function sortTable(table, order) {             var asc   = order === 'asc',             tbody = table.find('tbody');          tbody.find('tr').sort(function(a, b) {         if (asc) {             return $('td:first', a).text().localeCompare($('td:first', b).text());         } else {             return $('td:first', b).text().localeCompare($('td:first', a).text());         }     }).appendTo(tbody); } Call function when document loaded jQuery(document).ready(function() { sortTable($('#editable'),'asc'); }); 2. Sort the select option without empty value Html: <select id="contacts" class="filteroption" name="data[Candidateprofile][company]"> ...

How to add Validation rule in jQuery validation Plugin

How to add Validation rule in jQuery validation Plugin 1. Load the validate plugins <script src="js/jquery.validate.js"></script> 2. Now call the jQuery validate method <script> $(document).ready(function(){ // Add your own custom method  $("#old_password").rules('add',{remote:"check_password.php",  messages: {remote: "Passwords do not match"}});  $("#confirm_password").rules('add',{equalTo: "#password",   messages: {equalTo: "New password and confirm password do not match"}}); }); controller action $count=$this->Member->find('count',array( 'conditions'=>array('Member.password'=>md5($_GET['oldPass']), 'Member.id'=>$this->Session->read('Member.id'))));    if($count>0)    { echo 'true'; die;    } else { echo 'false'; die;   } // valid...

Bootstrap panel accordion with icons

Bootstrap panel accordion with icons HTML <div id="accordion" class="panel-group"> <div class="panel panel-default"> <div class="panel-heading"> <h5 class="panel-title"> <a href="#collapseOne" data-parent="#accordion" data-toggle="collapse" class="accordion-toggle">Profile</a> </h5> </div> <div class="panel-collapse collapse in" id="collapseOne"> <div class="panel-body"> <p>Hello Sudhir</p> </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h5 class="panel-title"> <a href="#collapseTwo" data-parent="#accordion" data-toggle="collapse" class="accordion-toggle">Profile</a> </h5> ...

Google Analytics in Cakephp

Implementation of Google analytics in cakephp. Create a element for it. app/views/elements/google-analytics.ctp : <?php $gaCode = Configure::read('google-analytics.tracker-code'); if ($gaCode) { $googleAnalytics = <<<EOD <script type="text/javascript">   var _gaq = _gaq || [];   _gaq.push(['_setAccount', '$gaCode']);   _gaq.push(['_trackPageview']);   (function() {     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);   })(); </script> EOD; echo $googleAnalytics; } ?> Call the element where you want. The best place to call element in layout. <?php echo $this->element('google-analytics...

Cakephp Route

If you want like this example.com/article/show-by-day.html example.com/article/slug-post.html Shows above url in route file like this Router::connect('/article/show_by_day',array('controller' => 'posts', 'action' => 'show'), array('pass' => array('show_by_day'))); Router::connect('/article/slug-post',array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug'))); Router::connect('/article/slug-post/:slug', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('slug'))); if route like Router::connect('/account', array('controller' => 'clientcontacts', 'action' => 'index', 'account' => true)); then its controller function is public function account_index() { }  its view file...

Cakephp Email Setting

Basic usage First of all, you should ensure the class is loaded using App::uses(): App::uses('CakeEmail', 'Network/Email'); Using CakeEmail is similar to using EmailComponent. But instead of using attributes you use methods. Example: $Email = new CakeEmail(); $Email->from(array('me@example.com' => 'My Site')); $Email->to('you@example.com'); $Email->subject('About'); $Email->send('My message'); To enable the transport, add the following information to your Config/email.php: You can configure SSL SMTP servers such as Gmail. To do so, prefix the host with 'ssl://' and configure the port value accordingly. Example: class EmailConfig {     public $gmail = array(         'host' => 'ssl://smtp.gmail.com',         'port' => 465,         'username' => 'my@gmail.com',         'password' => 'secret',         'transport' =...

PHP OOPS Concept

Encapsulation: Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. The wrapping up of data and methods into a single unit (called class) is known as encapsulation. The benefit of encapsulating is that it performs the task inside without making you worry. Polymorphism : Objects could be of any type. A discrete object can have discrete properties and methods which work separately to other objects. However a set of objects could be derived from a parent object and retain some properties of the parent class. This process is called polymorphism. An object could be morphed into several other objects retaining some of its behavior. Inheritance : The key process of deriving a new object by extending another object is called inheritance. When you inherit an object from another object, the subclass (which inherits) derives all the properties and methods of the superclass (which is inherited). A s...

PHP IMAP

**  * Uses PHP IMAP extension, so make sure it is enabled in your php.ini,  * extension=php_imap.dll  */  set_time_limit(3000);  /* connect to gmail with your credentials */ $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'YOUR_GMAIL_USERNAME'; # e.g somebody@gmail.com $password = 'YOUR_GMAIL_PASSWORD'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error()); $emails = imap_search($inbox,'ALL'); /* useful only if the above search is set to 'ALL' */ $max_emails = 16; /* if any emails found, iterate through each email */ if($emails) {     $count = 1;         /* put the newest emails on top */     rsort($emails);         /* for every email... */     foreach($emails as $email_number)     {         /* get information specific to this email */   ...

Cakephp testimonials

CakePHP testimonials Components and Plugins are still separate entities in Cake 2.0. According to the manual components are " are packages of logic that are shared between controllers ", whereas plugins are "a combination of controllers, models, and views". Compoments extend the base Component class, while Plugins have their own AppModel and AppController. Think of a plugin as a separate Cake application sharing the same core libraries with your main application. How to use vendor in cakephp App::import('Vendor', 'Custom/getdata'); $obj = new GetData(); Lib Contains 1st party libraries that do not come from 3rd parties or external vendors. This allows you to separate your organization’s internal libraries from vendor libraries. Vendor Any third-party classes or libraries should be placed here. Doing so makes them easy to access using the App::import(‘vendor’, ‘name’) function. Keen observers will note that this seems redundant, as ther...

Cakephp redirection

CakePHP Redirection Redirecting: $this->redirect(array('controller' => 'orders', 'action' => 'thanks')); Redirecting to website: $this->redirect('http://www.example.com'); Render the element for ajax: $this->render('/Elements/ajaxreturn'); Redirect to 404 not found: throw new NotFoundException('404 Error - Page not found'); If you need to redirect to the referer page you can use: $this -> redirect ( $this -> referer ()); If you need to redirect to the edit page with id: $this -> redirect ( array ( ’action’ => ’edit’ , $id )); Redirect to different action: $this -> render ( ’custom_file’ ); Call element in controller action $this->viewPath = 'Elements'; $this->render('sub_cat_list');