How to attach functionality to hooks ?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

How to attach functionality to hooks ?

Post by MantaPro »

I have a feeling I'm overlooking something obvious - sorry

I read with interest the stuff in some module help re. hooks available and in cmsmadesimple.org/documentation/programming/hooks and events

I've used hooks before and Ive added attached functionality to hooks in other CMSs before. The documentation provides examples of how hooks should be built in to a module; I've seen and understand the section on
Using (sending) Hooks which describes \CMSMS\HookManager::do_hook()


but I can't seem to find anything regarding where to put this hook functionality ?. For instance in another CMS, attaching to a hook is always placed in ready.php or init.php in the root directory the CMS is installed in

TIA
deactivated010521

Re: How to attach functionality to hooks ?

Post by deactivated010521 »

I am not sure if you are intrested in the HookManager as programmer or cmsms enduser?

From a programmers perspective read: ./lib/classes/class.HookManager.php to get a sense on what functionality is available.

There are many CMSMS core modules that implement the HookManager for example News: ./modules/News/action.addcategory.php -> NewsCategoryAdded hook. You can also implement the HookManager into your own module actions.

As enduser have a look at /admin -> Extensions -> Event Manager there you can see some in action.

I have to admit the CMSMS (enduser)documentation on the Event Manager is a bit sparse:
https://docs.cmsmadesimple.org/tags/event-manager

These are extensive:
https://docs.cmsmadesimple.org/advanced ... and-events
https://docs.cmsmadesimple.org/advanced/hooks-reference
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: How to attach functionality to hooks ?

Post by MantaPro »

Thank you for the reply Arnoud

kind of both - it was reading the module help for FEU and the CMSMS Docs section on Hooks & Events that prompted the question. Between those two I wonder if functionality could be added to hooks outside of a Module/ Event - particularly as in these documents the point is made that not all Hooks are Events - i.e. there are Cases which have a have a Hook but no Event

I suppose my use of other CMSs is muddying my understanding (where code snippets (which in CMSMS reside in UDTs and can be triggered via Events), in some other CMSs all hooks can be extended via code snippets added to a particular file in the filesystem (e.g. ready.php etc which is always loaded when the CMS initiates - i.e. outside of the database).

From your reply, with CMSMS hooks are for programmers use within their module; Events are for endusers within their UDTs in Admin. There is no extensibility of hooks outside of a module or UDT

Thanks for the clarification/confirmation Arnoud
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: How to attach functionality to hooks ?

Post by calguy1000 »

You can create a UDT to handle an Event.
That UDT CAN (though it is not a smart idea) emit hooks.

Modules can emit and handle hooks and events.

In the upcoming version of 2.3 everything will be 'hooks' so simple plugins and modules will be able to handle hooks.

No, there is no recommended simple 'php' file you can extend to inject your own php code, other than a module.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: How to attach functionality to hooks ?

Post by MantaPro »

Thanks for the update - good to know.

And thanks to you and the rest of the dev Team for all your hard work on CMSMS
Locked

Return to “CMSMS Core”