Rss Feed
  1. CSS browser selector

    Friday 17 May 2013


    For Firefox
    <style type="text/css">
    @-moz-document url-prefix() {
      .example {
       
        width: 960px;
    }
    }
    .ie .main_navi ul {
       width: 965px;
    }
    </style>

    For ie
    <!--[if IE]>
    <style type="text/css">
    .example {
       
        width: 965px;
    }
    </style>
    <![endif]-->


  2. Treat mysql longtext as integer in query

    SELECT  * FROM    mytable ORDER BY  myfield + 0


  3. <script>
      // A jQuery based placeholder polyfill
    $(document).ready(function(){
      function add() {
        if($(this).val() === ''){
          $(this).val($(this).attr('placeholder')).addClass('placeholder');
        }
      }

      function remove() {
        if($(this).val() === $(this).attr('placeholder')){
          $(this).val('').removeClass('placeholder');
        }
      }

      // Create a dummy element for feature detection
      if (!('placeholder' in $('<input>')[0])) {

        // Select the elements that have a placeholder attribute
        $('input[placeholder], textarea[placeholder]').blur(add).focus(remove).each(add);

        // Remove the placeholder text before the form is submitted
        $('form').submit(function(){
          $(this).find('input[placeholder], textarea[placeholder]').each(remove);
        });
      }
    });
     
      </script>

  4. Add this code in core.php

    Configure::write('baseUrl', 'http://localhost:9090/cakefoodnew/');






  5. <!-- Script - Title display for input text box-->
    <script type="text/javascript" language="javascript"> // <![CDATA[
          $(document).ready(function() {
    $('input[type="text"]').focus(function(srcc)
      {  ($(this).val() == $(this)[0].title)
      { $(this).removeClass("defaultTextActive");
                              $(this).val("");
      } });
    $('input[type="text"]').blur(function()
      { if ($(this).val() == "")
      { $(this).addClass("defaultTextActive");
                      $(this).val($(this)[0].title); }
    }); $('input[type="text"]').blur(); });
    // ]]>
    </script>


  6. Disabling Layouts and Views in CakePHP

    It is easy to disable both the layout and view in CakePHP by putting the following line in your controller action:

    $this->autoRender = false;

    If you want to disable just the layout, use the following line in your controller action:

    $this->layout = false;

    And if you only want to disable the view for this action, use the following line in your controller:

    $this->render(false);

    Note that using $this->layout = false; and $this->render(false); together in your controller action will give you the same results as $this->autoRender = false;

  7. Ajax function

    function ajaxRequest(){

    $this->layout = 'ajax'; // ajax plain layout
    $this->params['data']; // to get form submit values

    $this->params['url'];  // to get query string

    }