Skip to main content

Posts

CakePHP Interview Question and Answer

CakePHP Interview Question and Answer What is the first file that gets loaded when you run a application using cakephp? Answer: bootstrap.php     You can be changed it either through index.php , or through .htaccess     How to change via webroot > index.php         if (!defined('CAKE_CORE_INCLUDE_PATH')) {         if (function_exists('ini_set')) {             ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));         }         if (!include('Cake' . DS . 'bootstrap.php')) { // Change bootstrap.php file to any file name             $failed = true;         }     } else {         if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {             $failed = true;     ...

Javascript Local Storage

Javascript Local Storage LocalStorage is used to stored web application data within the user's browser. LocalStorage is only store strings in the different keys How to check user's browser support? if (typeof(Storage) !== "undefined") {     // Code for localStorage/sessionStorage. } else {     // Sorry! No Web Storage support.. } How to Set Values in localStorage localStorage. setItem ('favoriteflavor','vanilla'); How to Access localStorage variable If you read out the favoriteflavor key, you will get back “vanilla”: var taste = localStorage. getItem ('favoriteflavor'); How to remove Elements from localStorage localStorage. removeItem ('favoriteflavor'); var taste = localStorage.getItem('favoriteflavor'); How to Store Array in LocalStorage localStorage is for key : value pairs, so what you'd probably want to do is JSON.stringify the array and store the string in the mycars key and then you can pul...

YouTube Player API Reference for iframe Embeds

YouTube Player API Reference for iframe Embeds The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript.Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played. <script>       // 1. This code loads the IFrame Player API code asynchronously.     var tag = document.createElement('script');     tag.src = "https://www.youtube.com/iframe_api";     var firstScriptTag = document.getElementsByTagName('script')[0];     firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);     // 2. This function creates an <iframe> (and YouTube player)     //    after the API code downloads.     var player;            f...

Implementation of CKEDITOR with javascript

Implementation of CKEDITOR with javascript Html Portition             <!DOCTYPE html> <html>     <head>         <meta charset="utf-8">         <title>CKEditor</title>         <!-- Make sure the path to CKEditor is correct. -->         <script src="../ckeditor.js"></script>     </head>     <body>         <form>             <textarea name="editor1" id="editor1" rows="10" cols="80">                 This is my textarea to be replaced with CKEditor.             </textarea>         </form>     </body> </html> Script Portition <script>     $(function(){   ...

Create Plugins in Cakephp

How To Create Plugins in CakePHP Step 1: inside /app/Plugin Folder create a folder "Admin" Here "Admin" is plugin name. Step 2: How to load plugin. Either you load Plugin in bootstrap.php file or in any controller action. Use: CakePlugin::load('Admin'); /app/Plugin/Admin/Model/AdminAppModel.php: class AdminAppModel extends AppModel { } Step 3: Create Controller inside plugin // app/Plugin/Admin/Controller/ContactsController.php If you want to be able to access your plugin with a URL, defining an AppController for the plugin is required. App::uses('AppController', 'Controller'); class AdminAppController extends AppController { } class ContactsController extends AdminAppController { public $uses = array('Admin.Contact'); public function index() { //... } } Note: You can do inter-plugin communication by using $this->requestAction('/plugin_name/controller_name/action...

Google reCAPTCHA using PHP and jQuery

Google reCAPTCHA using PHP and jQuery. A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. It is usually a graphic image with a series of distorted letters on an equally distorted or multicolored background. Google has released the new reCAPTCHA . Using reCAPTCHA users can prove they are human without solving a CAPTCHA. Steps for google reCAPTCHA implementation. 1. Create a secure key and site key Register your site at Google from here – https://www.google.com/recaptcha/admin      2. Html Code Now first of all include Google reCAPTCHA javascript library. <script src="https://www.google.com/recaptcha/api.js" async defer></script> Now in form body section add reCAPTCHA DIV element <form action="" method="POST">     <input type="text" name="name" value="" />     <input type="text" name=...

Search Table Row by jquery

Search Table Row by jquery Search content from table using jQuery. Live searching method via jquery Create function to remove highlight content. If content not matched. function removeHighLighting (elm){         elm.each(function(){             var element = $(this);             element.replaceWith(element.html());         })     } Create function to highlight matched content. function addHighLighting (elm, data){         var text = elm.text();         var highlightedText = '<em>' + data+ '</em>';         var newText = text.replace(data, highlightedText);         elm.html(newText);     } Search text on keyup $("#search").on("keyup", function() {     ...