Last active
February 4, 2016 21:50
-
-
Save arysom/5388342 to your computer and use it in GitHub Desktop.
Codeigniter vim snippets. https://gist.github.com/channeleaton/864821 plus snipps for my_model, and template spark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##### CodeIgniter Snippets ##### | |
| # Generic $this-> | |
| snippet this | |
| $this->${1:model/controller}->${2:method}(${3:array});${4} | |
| # New Model Class | |
| snippet classm | |
| <?php | |
| /* | |
| * ${1:Describe the model's purpose} | |
| */ | |
| class ${2:model name} extends CI_Model | |
| { | |
| function __construct() | |
| { | |
| parent::__construct(); | |
| } | |
| ${3:// Code...} | |
| } | |
| # New Controller Class | |
| snippet classc | |
| <?php | |
| defined('BASEPATH') OR exit('No direct script access allowed'); | |
| /* | |
| * ${1:Describe the controller's purpose} | |
| */ | |
| class ${2:controller name} extends CI_Controller | |
| { | |
| function __construct() | |
| { | |
| parent::__construct(); | |
| } | |
| ${3:// Code...} | |
| } | |
| # Form Validation Rules | |
| snippet formrule | |
| $this->form_validation->set_rules('${1:field name}','${2:human name}', '${3:rules}');${4} | |
| # Data array - $data['key'] | |
| snippet darr | |
| $data['${1:arrayName}'] = array( | |
| '${2}' => ${3},${4} | |
| ); | |
| # Additional array data | |
| snippet arrv | |
| '${1}' => ${2},${3} | |
| # Load view template | |
| snippet loadtemp | |
| $data['main_content'] = '${1:view}'; | |
| $this->load->view('includes/template', $data);${2} | |
| ##### Form Helper ##### | |
| # Validation Errors | |
| snippet valerr | |
| echo validation_errors(); ${1} | |
| # label | |
| snippet flabel | |
| echo form_label('${1:label}'); ${2} | |
| # Form Open | |
| snippet formo | |
| echo form_open('${1:form controller}'); ${2} | |
| # Form Close | |
| snippet formc | |
| echo form_close(); ${1} | |
| ## Form Fields ## | |
| # Hidden | |
| snippet fhidden | |
| echo form_hidden('${1:name}', ${2:array}); ${3} | |
| # Input | |
| snippet finput | |
| echo form_input('${1:array}', set_value('${2:name}')); ${3} | |
| # Password | |
| snippet fpass | |
| echo form_password('${1:array}', set_value('${2:name}')); ${3} | |
| # Upload | |
| snippet fupload | |
| echo form_upload('${1:array}', set_value('${2:name}')); ${3} | |
| # Text area | |
| snippet ftext | |
| echo form_textarea('${1:array}', set_value('${2:name}')); ${3} | |
| # Drop-down | |
| snippet fdrop | |
| echo form_dropdown('${1:name}',${2:array}, $this->input->post('${1}')); ${3} | |
| # Checkbox | |
| snippet fcheck | |
| echo form_checkbox($${1:array}['${2:key}'], '', set_checkbox('${1}[]', '${2}')); ${3} | |
| # Radio button | |
| snippet fradio | |
| echo form_radio($${1:array}['${2:key}'], '', set_radio('${1}[]', '${2}')); ${3} | |
| # Form submit | |
| snippet fsubmit | |
| echo form_submit('${1:name}', '${2:value}'); ${3} | |
| # Form reset | |
| snippet freset | |
| echo form_reset('${1:name}', '${2:value}'); ${3} | |
| # Fieldset open | |
| snippet fieldo | |
| form_fieldset('${1:label}', '${2:array}'); ${3} | |
| # Fieldset close | |
| snippet fieldc | |
| form_fieldset_close(); ${1} | |
| ##### URL Helper ##### | |
| # Site URL | |
| snippet surl | |
| echo site_url("${1:segments}"); ${2} | |
| # Base URL | |
| snippet burl | |
| echo base_url(); ${1} | |
| # Current URL | |
| snippet curl | |
| echo current_url(); ${1} | |
| # Anchor | |
| snippet anchor | |
| echo anchor('${1:segments}', '${2:text}', '${3:attributes}'); ${4} | |
| # Safe Mailto | |
| snippet mailto | |
| echo safe_mailto('${1:email}', '${2:text}'); ${3} | |
| ### And some of my specified use ### | |
| #assign post to vars | |
| snippet post | |
| $${1}=$this->input->post('${2}');${3} | |
| # redirect | |
| snippet redire | |
| redirect('../${1}', 'refresh');${2} | |
| #set flashdata messa | |
| snippet message | |
| $this->session->set_flashdata('message','${1}');${2} | |
| #language line, you need eco it | |
| snippet ll | |
| $this->lang->line('${1}')${2} | |
| ### my_model jamie rumbelow ### | |
| #get all | |
| snippet gall | |
| $${1}=$this->${2}_model->get_all();${3} | |
| #get by id | |
| snippet gid | |
| $${1}=$this->${2}_model->get($id);${3} | |
| #get many by | |
| snippet gmany | |
| $${1}=$this->${2}_model->get_many_by(${2},${3});${4} | |
| #order_by | |
| snippet ordby | |
| ->order_by(${1},${2})${3} | |
| #limit | |
| snippet limit | |
| ->limit(${1},${2})${3} | |
| #insert | |
| snippet myins | |
| $this->${1}_model->insert(array(${2}));${3} | |
| #update | |
| snippet myupd | |
| $this->${1}_model->update($id,array(${2}));${3} | |
| #delete | |
| snippet mydel | |
| $this->${1}_model->delete($id);${2} | |
| #exmaple my_model | |
| snippet classmm | |
| <?php | |
| class ${1}_model extends MY_Model | |
| { | |
| public $before_create = array( 'created_at', 'updated_at' ); | |
| public $before_update = array( 'updated_at' ); | |
| }${2} | |
| ### phil sturgeons template lib ### | |
| snippet temp | |
| $this->template->title($${1},'${2}') | |
| ->set_metadata('description',$${3}) | |
| ->build('${4}',array(${5}));${6} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment