Welcome Guest, Not a member yet? Register   Sign In
What is hook
#1

[eluser]Muhammad Faisal Shabbir[/eluser]
hai to all
can some one help me to understanding the hook and why we use it in CI very frequently
#2

[eluser]xwero[/eluser]
A hook is a method or a function you want to execute during one of the different stages of the page build up (short explaination).
CI calls the stages hook points.

You have to use hooks wisely because they can slow down the page build.
#3

[eluser]Muhammad Faisal Shabbir[/eluser]
Thanx for ur assistence xwero
#4

[eluser]ELRafael[/eluser]
Man, really? I believed that hook is from Neverland. Ok, sorry!

An example for hook is to test if user is logged in the system. You have a function that you wana run before the method.So you use inside hoook.
#5

[eluser]Nick Husher[/eluser]
Hooks are a way of introducing Aspect-oriented Programming into your system, as well. Like ElRafael noted, you can use it to check a user's logged-in status, you could also use it for logging, or checking database sanity (probably a bad idea, but possible). Anything that you want executed every time a page loads, or any program responsibility you want to apply broadly across your system, you might want to put in a hook.
#6

[eluser]JOKERz[/eluser]
did you use hook to check user logged-in status in your code??
#7

[eluser]Nick Husher[/eluser]
I haven't personally, but I could if I wanted to. It probably introduces a level of complexity that you don't need in small projects (lightweight CMSes, etc) but in a larger environment where your login might be somewhat more complicated or it exists on every page, moving that code into a hook might be helpful.
#8

[eluser]JOKERz[/eluser]
hmm.... i see....
thanks for your advise.
#9

[eluser]Majd Taby[/eluser]
check out http://ellislab.com/forums/viewthread/67126/ for a live example of how to use hooks to secure a whole application.




Theme © iAndrew 2016 - Forum software by © MyBB