So far my searches in this forum have proved futile regarding hooks......
Since I am using 1.1, I've been trying to manually install add ons..
Take "Users Online Today" Mod for example..
<install for="1.0 - 1.0.99">
<require-file name="OnlineToday.class.php" destination="SUBSDIR" />
<require-file name="OnlineToday.template.php" destination="THEMEDIR" />
<require-file name="OnlineToday.english.php" destination="LANGUAGEDIR" />
<hook hook="integrate_action_boardindex_after" file="SUBSDIR/OnlineToday.class.php" function="Online_Today_Integrate::get" />
<hook hook="integrate_general_mod_settings" file="SUBSDIR/OnlineToday.class.php" function="Online_Today_Integrate::settings" />
</install>
What I did was, I manually uploaded the three files..
And then..... I'm stuck. Hook what? I searched through all the files in Elkarte, but there's not much going on about hooks (which I can understand at least)..
I thought that all I needed to do was to add the hook codes to a file which stores all hooks... boy was I wrong.. :p
Anyone patient enough to explain to me about hooks and how it works and what I should do, etc? :D
/me is hopeful
Is the package manager not working with them?
Yeah it wouldn't install it.. :(
Did you actually enable it in admin > config > addons-settings > miscellaneous?
Because:
http://www.elkarte.it/elk1.1/index.php
it's not exactly up-to-date, but I don't remember anything major changed between this and beta1.
OMG.. I didn't know online today was a built in function in 1.1!!!!!!!!!!!!!
Wow, you saved me a lot of work! :D :D :D
I still don't get all the hooks stuff and all that but yeah this solved the problem for this feature I need....... :D Thanks!
No, it's not a built in function, I installed the addon from http://addons.elkarte.net/enhancement/Users-Online-Today.html , went to the admin page and picked the "version" of the online I wanted to display.
Let's solve this one, later I'll explain hooks. :P
Ahh I see the problem now. I installed a fresh Beta 1.1 and yeah it doesn't have that add on.......
I think what happened was that I installed that add on....... and the installation failed (and isn't showing in the installed packages as well), BUT SOMEHOW.... the hooks were installed. :D LOL
at would be a bug, though! :P
Anyway, hooks are "places" in the code where functions defined by addons (or by the "core") can be run to extend functionalities.
For example, let's take: integrate_general_mod_settings
If you search the code, you'l find:
call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
in AddonsSettings.controller.php.
What does that mean?
It means that every time the code hits that point, any function "attached" to the "integrate_general_mod_settings" hook will be called passing the variable $config_vars (by reference).
How are functions "attached" to a certain hook?
Two ways:
<hook hook="hook_name" file="SOURCEDIR/my_file_to_include.php" function="my_function_to_call" />
in package-info.xml, or calling something like:
add_integration_function('hook_name', 'my_function_to_call', 'SOURCEDIR/my_file_to_include.php');
the fist is simply an alternative way to call the second method.
These will add or update an entry in the {db_prefix}settings table adding the relevant data to let Elk know there is a function to call at a certain point in the code.
In 1.1 I also added another way to extend Elk, the things I called "events".
More stuff:
http://www.elkarte.net/community/index.php?topic=2192.0
http://www.elkarte.net/community/index.php?topic=831.msg16689#msg16689 (and following)
Maybe there is more... for sure it should be consolidated on the wiki or something...
This is what happenes when I install add ons..
Connection Problems
Sorry, we were unable to connect to the database. This may be caused by the server being busy. Please try again later.
Ps: still processing what you wrote.. lots to read and understand. :)
Any time you install any addon?
And only when you install addons?
O_O
Yeah, like the "Users Online Today" mod, it gives that error, and nothing is shown as installed....
BUT the hooks are added already.. and as for the files, they uploaded empty files, but I manually uploaded the right files already.
So yeah it works in the end. :D But only after "hacking" it...
Seems like the same problems as mine in 1.1 beta 2 here: http://www.elkarte.net/community/index.php?topic=3984.0
I guess it was not tracked nor fixed since 1.1. beta 1.