Jump to content
SuperPower09

ELI5: Hooks vs. Modules (Bootstrap Edition)

Recommended Posts

I have an old version of osCommerce (2.3.4) I'm going through the process of getting familiar with the CE version of osCommerce (the Bootstrap 4 version).

Overall, I'm trying to find the best way to customize things without touching the core...too much.

Let's say I wanted to do a few simple things:

- Add an ad banner or two to the home/index.php page
- Add a custom div to the product_info page

Would a module or a hook even be appropriate for setting these up? I guess, I'm not sure as to when I should use either a hook or module.

I could be wrong but creating a module for this seems like way too much work. However, looking at the hook system, this looks like it would be simpler. Am I wrong in that assumption?

Share this post


Link to post
Share on other sites

In the product_info.php file, you will see a command to get_content. That loads in all of the modules for that page. You can control the sort order of them within that section. But it doesn't load hooks. With hooks, you have to add code to load them in. They are easier to write than modules but can't be sorted with the modules.  So which you use depends on what you want to do.

If you just want to add a banner to a page that doesn't change, a hook might be the best choice. But if you want to be able to control it a little more easily, the module would be better.

But before you do any of that, look at already completed addons.  The jssor slider will do what you want and save you a lot of time coding. And there are quote a few other banner-type modules beside that one.

Share this post


Link to post
Share on other sites

2.3.4.1BS "Frozen" is stable and production ready. 2.3.4.1BS "Edge" is still under development, can change day to day, and is considered "unstable" (although, quite usable). You should use Frozen (which is Bootstrap 3) unless you have an overriding need for Bootstrap 4 (Edge) and you're willing to put up with instabilities in your production store.


If you are running the "official" osC 2.3.4 or 2.3.4.1 download, your installation is obsolete! Get (stable) Frozenpatches or (unstable) Edge. See also the naming convention and the latest community-supported responsive "Edge" release

Share this post


Link to post
Share on other sites

@SuperPower09I didn't notice you mentioned Bootstrap 4. My comment about existing addons doesn't apply to it. If you are just playing around, it is fine to use that version but for a production shop, it should be the BS 3 version as @MrPhil mentioned.

Share this post


Link to post
Share on other sites

@Jack_mcs @MrPhil

 

Thank you both, I really appreciate your feedback. I can definitely see sorting the modules playing a part in my layout so I'll keep that in mind. I've also found a few threads with some good examples so I'll go through those too.

Oh, and I'm only using Bootstrap 4 version to mess around for now. I plan on finalizing my project towards the end of the year so I wanted to get familiar with both BS3 and BS4.

Thanks again guys!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×