Advertisement:

Author Topic: Do these hooks exists for smf 2.0x?  (Read 689 times)

Offline doug_ips

  • Jr. Member
  • **
  • Posts: 298
Do these hooks exists for smf 2.0x?
« on: April 22, 2019, 04:50:01 PM »
I am working a couple of mods that will add extra options/settings to the Maintenance and Tasks. As far as I could see there are no hooks to add in those 2 areas. Am I right or have I missed them?

Online SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,401
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Do these hooks exists for smf 2.0x?
« Reply #1 on: April 22, 2019, 05:05:05 PM »
I don't really know,

All hooks are listed here https://wiki.simplemachines.org/smf/Integration_hooks

Usually when I make a mod, I look for a call to "call_integration_hook" around the area I wish to customize, so if you can't find one, then there isn't. SMF2.0 is very poor in hooks, SMF2.1 on the hand is full of them so I really don't think mod authors will have to modify the code at all except for a few rare cases for that version.

Imazighen

Offline Suki

  • Kaizoku Jotei
  • Developer
  • SMF Super Hero
  • *
  • Posts: 15,463
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Do these hooks exists for smf 2.0x?
« Reply #2 on: April 22, 2019, 05:05:30 PM »
Do you mean scheduled tasks? if so, you have to add yours in the corresponding table,  something like scheduled_tasks or so, can't remember correctly the actual table name.  Check a mod that adds a scheduled task to see for yourself, I got one for posting birthdays.

I can't remember if theres a hook for maintenance.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline doug_ips

  • Jr. Member
  • **
  • Posts: 298
Re: Do these hooks exists for smf 2.0x?
« Reply #3 on: April 22, 2019, 05:19:04 PM »
I don't really know,

All hooks are listed here https://wiki.simplemachines.org/smf/Integration_hooks

Usually when I make a mod, I look for a call to "call_integration_hook" around the area I wish to customize, so if you can't find one, then there isn't. SMF2.0 is very poor in hooks, SMF2.1 on the hand is full of them so I really don't think mod authors will have to modify the code at all except for a few rare cases for that version.

I did look but I could find any. I thought that maybe I missed it, but now I see that I was right in my assumtion that there are no hooks for those areas. I am glad to read that about 2.1. It will make coding/developing mods much much easier.

Do you mean scheduled tasks? if so, you have to add yours in the corresponding table,  something like scheduled_tasks or so, can't remember correctly the actual table name.  Check a mod that adds a scheduled task to see for yourself, I got one for posting birthdays.

I can't remember if theres a hook for maintenance.

Yes, I meant the scheduled tasks. And yes, I have added it to the smf_ scheduled_tasks as well.

Many thanks for your replies guys.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,319
  • Gender: Male
    • Kindred-999 on GitHub
Re: Do these hooks exists for smf 2.0x?
« Reply #4 on: April 22, 2019, 07:23:03 PM »
check the RSS Feed importer mod... I know that one adds a scheduled task
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Sesquipedalian

  • The Mad Doctor
  • On Hiatus
  • Sr. Member
  • *
  • Posts: 908
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Do these hooks exists for smf 2.0x?
« Reply #5 on: April 23, 2019, 03:14:26 AM »
FYI, you can create your own hooks at any arbitrary place in the SMF 2.0.x code that you like. Just use modification.xml to insert a single line like this where appropriate:

Code: [Select]
call_integration_hook('modname_funcname', array(&var1, &var2));

Then use the normal methods in your mod package for connecting your mod's functions with the hook.

This approach keeps your file edits nice and clean (only one line added), and allows you to use the same code in both 2.0 and 2.1 without any significant rewrites.

For an example of how to do this, feel free to look at the 2.0 install code I use in my Paragrapher mod.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,216
    • StoryBB/StoryBB on GitHub
Re: Do these hooks exists for smf 2.0x?
« Reply #6 on: April 23, 2019, 04:12:00 AM »
The real trick is hijacking existing hooks to do things because other hooks don’t exist ;D LevGal has a great example, there’s no hook in 2.0 to do stuff on the back of deleting a group (no tidy up option there) but careful manipulation of other hooks means it does become possible to do...

Just hard work and ugly though :( and the less we say about abusing integrate_buffer the better.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline doug_ips

  • Jr. Member
  • **
  • Posts: 298
Re: Do these hooks exists for smf 2.0x?
« Reply #7 on: April 23, 2019, 08:30:31 AM »
Thanks for the tips guys, really appreciate it.