CodeIgniter For Project : Lesson 105 - Helper and Library

21
CodeIgniter For Project Lesson 105 : Helper and Library Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd https://kusumotolab.com

Transcript of CodeIgniter For Project : Lesson 105 - Helper and Library

Page 1: CodeIgniter For Project : Lesson 105 - Helper and Library

CodeIgniter For ProjectLesson 105 : Helper and Library

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 2: CodeIgniter For Project : Lesson 105 - Helper and Library

Helper

“Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular

category”

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 3: CodeIgniter For Project : Lesson 105 - Helper and Library

Helper load code

• $this->load->helper([helper name]);

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

You can load helper on constructor and function in Controller

Page 4: CodeIgniter For Project : Lesson 105 - Helper and Library

Helper frequently used

• url : URL helper utility

• form : Form helper utility

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 5: CodeIgniter For Project : Lesson 105 - Helper and Library

url : URL helper utility

• site_url() : Get current url your website.

• base_url() : Get current base path.

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 6: CodeIgniter For Project : Lesson 105 - Helper and Library

url : URL helper utility• base_url()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 7: CodeIgniter For Project : Lesson 105 - Helper and Library

url : URL helper utility• site_url()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 8: CodeIgniter For Project : Lesson 105 - Helper and Library

form : Form helper utility

• form_open() : Auto form open generate

• form_close() : Auto form close generate

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 9: CodeIgniter For Project : Lesson 105 - Helper and Library

form : Form helper utility• form_open()

• form_close()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 10: CodeIgniter For Project : Lesson 105 - Helper and Library

Library

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 11: CodeIgniter For Project : Lesson 105 - Helper and Library

Library load code

• $this->load->library([library name]);

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

You can load library on constructor and function in Controller

Page 12: CodeIgniter For Project : Lesson 105 - Helper and Library

Library frequently used

• session : CodeIgniter session library

• input : CodeIgniter input library (autoload)

• load : CodeIgniter library loader (autoload)

• form_validation : CodeIgniter form validate library

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 13: CodeIgniter For Project : Lesson 105 - Helper and Library

session : CodeIgniter session library

• $this->session->set_userdata() : Set user data session

• $this->session->unset_userdata() : Unset user data session

• $this->session->userdata() : Read data from session

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 14: CodeIgniter For Project : Lesson 105 - Helper and Library

session : CodeIgniter session library• $this->session->set_userdata()

• $this->session->unset_userdata()

• $this->session->userdata()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 15: CodeIgniter For Project : Lesson 105 - Helper and Library

input : CodeIgniter input library (autoload)

• $this->input->post() : Get value from post method

• $this->input->get() : Get value from get method

• $this->input->cookie() : Get value from cookie

• $this->input->server() : Get value from server variable

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 16: CodeIgniter For Project : Lesson 105 - Helper and Library

• $this->input->post()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

input : CodeIgniter input library (autoload)

Page 17: CodeIgniter For Project : Lesson 105 - Helper and Library

• $this->input->get()

input : CodeIgniter input library (autoload)

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 18: CodeIgniter For Project : Lesson 105 - Helper and Library

form_validation : CodeIgniter form validate library

• $this->form_validation->set_rules() : Set form validate rule

• $this->form_validation->run() : Begin validation from rules

• validation_errors() : Show error if validation not pass

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 19: CodeIgniter For Project : Lesson 105 - Helper and Library

form_validation : CodeIgniter form validate library

• $this->form_validation->set_rules()

• $this->form_validation->run()

• validation_errors()

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Page 20: CodeIgniter For Project : Lesson 105 - Helper and Library

form_validation : CodeIgniter form validate library

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com

Rules in set_rules method

Page 21: CodeIgniter For Project : Lesson 105 - Helper and Library

Forward to Workshop 004

Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd

https://kusumotolab.com