We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How can you tell when you need to build an extension ?

Development and Programming

vincej's avatar
vincej
172 posts
12 years ago
vincej's avatar vincej

Hi - I am learning how to build a module using Low’s / Mijingo video tutorial. In that an extension is used and built to support the new module.

As a newb, how in the world do you know when you need an extension. I mean the user guide has extensions all wrapped up with with Hooks. Ok, how do I know when I need a hook ??

Other than memorising the 100 or so hooks what are the essential rules to when you need a hook or an extension ?

Many thanks !

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

Hi vincej,

Extensions and hooks are normally used when you want to change or extend how ExpressionEngine performs a certain task. For example, we have an email_send hook which is fired any time EE sends an email. That hook gives you the ability and option to alter the email before it’s sent, or you can take over sending the email all together and prevent EE from running its email sending code. Other hooks for example can alter the data queried by a Channel Entries tag or perform actions when a user logs in or out of the system. If you take a look at the rest of the hooks in the Extensions Development section, most should have a summary or example of what the hook can be used for, and that should give you a better idea of when to use hooks.

Kevin

       
vincej's avatar
vincej
172 posts
12 years ago
vincej's avatar vincej

HI Kevin - thank you for the help. here is my issue: I come from a CodeIgniter / PHP background where everything is coded. Ok, so now I am coding in EE … how will I know that, … Opps now I need an extension. … now I need a hook. I mean, there are dozens of them, and other than memorizing all of them, I will never be able to distinguish when I need a hook/extension and when I won’t. I mean, I see myself coding away in EE totally oblivious that I am hitting a brick wall which can be overcome with a hook.

Bottom line, other than memorizing the dozens of hooks, how do you know ? Or is it just a simple case of memorizing ?

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
12 years ago
Kevin Cupp's avatar Kevin Cupp

I think of hooks as event-based. So if you’re coding an addon and find yourself saying, “hmm I really need to run some code after a user submits an entry,” or “I need a way to alter template contents after it’s run through the parser,” then you’ll know you need a hook, then it’s a matter of looking through our hooks documentation to find the hook you need, and hopefully we have a hook to help you out. I don’t think you’d need to memorize every hook, but maybe just skim through the hooks list to get an idea of what hooks are used for and when they’re called in the system:

http://ellislab.com/expressionengine/user-guide/development/extension_hooks/

Then maybe if you encounter a problem, you’ll say, “oh I think there may be a hook for this.” Another way to think about hooks is modules can only really run in templates, and they can have their own pages in the backend of the control panel. If you need code executed outside of those two places, you probably need a hook.

Since you’re familiar with CodeIgniter, maybe take a look at CI’s hook documentation. So yes, while everything is coded in CI, there are still certain events you may want to override or simply run some code during:

http://ellislab.com/codeigniter/user-guide/general/hooks.html

       
vincej's avatar
vincej
172 posts
12 years ago
vincej's avatar vincej

Thanks !! It’s a good explanation. I never felt the need to use a hook in CI. If I hit a brick wall, I just went to PHP for a bit, then returned back to CI.

I’m sure it’s me, however, I do find learning and coding EE modules much much harder to work with than CI. The EE tag language is quite obscure.

Many Thanks !

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.