Category:Help -> TipsAndTricks | Category:Help -> Eclipse
Three basic templates for those people using eclipse PDT for working with codeigniter
controller
model
library
To add these go to ‘preferences > php > templates > new’ and remember to set the ‘context’ in the dialog to ‘new php’ it will then be available as a new template when adding a new php file.
NB: make sure there are no spaces before or after the code in your templates otherwise you will fall foul of ‘headers already sent’.
1: controller
<?php
class ${Foo} extends Controller {
function ${Foo}()
{
parent::Controller();
}
function ${index}()
{
${cursor}
}
}
/* End of file foo.php */
/* Location: ./system/application/controllers/foo.php */
2: Model
<?php
class ${Foo_model} extends Model
{
function ${Foo_model}()
{
parent::Model;
}
function ${get_xxx}()
{
}
function ${add_xxx}()
{
}
function ${edit_xxx}()
{
}
function ${delete_xxx}()
{
}
}
/* End of file foo_model.php */
/* Location: ./system/application/models/foo_model.php */
3. Library
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class ${Classname}
{
function ${Classname}()
{
$$this->CI =& get_instance();
${cursor}
}
}
/* End of file class.php */
/* Location: ./system/application/libraries/class.php */
