Saturday, 5 May 2012

Master page Codeigniter Library

SA,

I was an Asp.Net Developer Before Starting Php , One of the Best Concepts in Asp.Net is the Master page which simplify working with our views by  adding a common layout for all pages

Then I Found out  that the layout divided into header , footer , sidebar which are constant in design all over the website just differs in content and the main content which differs according to the requested URL

Here's a Link to the Master Page Library that's help in that task with simple and less Code

1. Configuration :
  • sub_path : The path of your view files in views folder
  • master_output : The Output of Your Master page ('view' , 'parser')
  • header : Name of Your Header File 
  • footer :  Name of Your Header File 
* Note :  Each of these Parameters has default values ("front" , "view" , "header.php" , "footer.php" ) respectively 

2. Functions : 
  • apply($page, $data, $type = 'view', $lang = '', $return = '0')  and it's used to apply common layout
  • apply_ajax($page, $data, $type = 'view', $lang = '', $return = '0') and it's used to apply partial view as in ajax
    • $page : view file name 
    • $data : the data for view
    • $type : type of rendering the current page Default is "view"
    • $lang : used for language folder (could be any sub-folder with sub_path) Default is empty
    • $return : either to return the view in string or in  browser Default is FALSE
3. Example : 

  • Controller Constructor
       
        $config['sub_path'] = 'admin';
        $config['master_output'] = 'view';
        $config['header'] = 'header.php';
        $config['footer'] = 'footer.php';

        $this->masterpage->intialize($config);

  • Controller Function
              $this->masterpage->apply($page , $data);
                   

Tuesday, 1 May 2012

CodeIgniter Autocomplete for IDEs

SA,

This was one of  my worst Nightmares , To find an IDE or Editor that rapids the development of CodeIgniter Framework as its one of the best MVC Pattern framworks and its easy to learn , deploy


I had installed too many IDEs and finally found that NetBeans, PhpDesigner and Komodo Edit are the best with some issuses

1. Netbeans : has a problem with Arabic support (fonts and direction of text)
                   : doesn't have a built-in FTP support
                   :  Use Many Resources (RAM)

2. PhpDesigner : Expensive
                       : Doesn't Support Code Folding

3. Komodo Edit : Some parse Errors when file contains (html,css,php) together
                       : FTP Client Hangs while Downloading or Uploading files

Now I am with Komodo Edit


For Codeigniter AutoComplete  Its a Simple task  but its hard to find

Here is the steps

1.  Go to  {codeigniter folder}/system/core/Controller.php
2.  In the PHPDoc For the Class add the Following Lines



 * @property CI_DB_active_record $db
 * @property CI_DB_forge $dbforge
 * @property CI_Benchmark $benchmark
 * @property CI_Calendar $calendar
 * @property CI_Cart $cart
 * @property CI_Config $config
 * @property CI_Controller $controller
 * @property CI_Email $email
 * @property CI_Encrypt $encrypt
 * @property CI_Exceptions $exceptions
 * @property CI_Form_validation $form_validation
 * @property CI_Ftp $ftp
 * @property CI_Hooks $hooks
 * @property CI_Image_lib $image_lib
 * @property CI_Input $input
 * @property CI_Language $language
 * @property CI_Loader $load
 * @property CI_Log $log
 * @property CI_Model $model
 * @property CI_Output $output
 * @property CI_Pagination $pagination
 * @property CI_Parser $parser
 * @property CI_Profiler $profiler
 * @property CI_Router $router
 * @property CI_Session $session
 * @property CI_Sha1 $sha1
 * @property CI_Table $table
 * @property CI_Trackback $trackback
 * @property CI_Typography $typography
 * @property CI_Unit_test $unit_test
 * @property CI_Upload $upload
 * @property CI_URI $uri
 * @property CI_User_agent $user_agent
 * @property CI_Validation $validation
 * @property CI_Xmlrpc $xmlrpc
 * @property CI_Xmlrpcs $xmlrpcs
 * @property CI_Zip $zip



3. Save File and Reload Project
* Note  You Can add any Custom Library , Model as follows
 [@property {Class_Name} {Object_Name}  ] , it will be autocompleted