ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Burke Knight on July 07, 2015, 08:55:51 pm

Title: Known Hook addons not working right
Post by: Burke Knight on July 07, 2015, 08:55:51 pm
Okay, I know my addon works, as I have it installed on a few sites, but it seems whenever I install, it installs and the boxes in settings show up, but they do nothing, when enter anything into them.

After some time, it seems it just starts working, usually.
We mentioned this in another topic, where someone had a similar issue with an addon.
I think this needs to be tracked.
Title: Re: Known Hook addons not working right
Post by: Spuds on July 07, 2015, 09:07:47 pm
Thats very strange indeed.  ... I'll would take a look but I'm pretty much unable to do anything until next week as I'm traveling ATM and will not be home until then :(
Title: Re: Known Hook addons not working right
Post by: emanuele on July 08, 2015, 02:44:13 am
Moar info needed. :P

Quote from: Burke Knight – Okay, I know my addon works, as I have it installed on a few sites, but it seems whenever I install, it installs and the boxes in settings show up, but they do nothing, when enter anything into them.
Any one of your addons? Or just some in particular? If the latter which?

Quote from: Burke Knight – We mentioned this in another topic, where someone had a similar issue with an addon.
Which topic? Do you remember it?
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 08, 2015, 07:06:50 am
Addon is my Global Header & Footer.
As for the topic, I don't remember, but when get back to my pc, I'll look through my posts to find it.

The BBC Move topic... http://www.elkarte.net/community/index.php?topic=1750.msg18572#msg18572
Title: Re: Known Hook addons not working right
Post by: ahrasis on July 08, 2015, 06:29:33 pm
The hook version or non-hook? If I am not mistaken, you didn't put div or table for your addon position. Can adding that fixes your problem?
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 08, 2015, 06:33:57 pm
The hooks version, hence the title.... LOL :)

That should not matter, and did not for the other sites, including the demo site, where it finally started working, after a bit of time.

That's the strange part, and it's not browser cache, either, as even others could not see what was entered, including statcounter, when added the code, it said code was not present.
Title: Re: Known Hook addons not working right
Post by: ahrasis on July 08, 2015, 07:21:47 pm
Strange indeed. It could be your database problems. Or some files could be missing their contents. They happen sometimes.
Title: Re: Known Hook addons not working right
Post by: emanuele on July 09, 2015, 02:54:21 am
Installed locally without problem....
It started working immediately after I clicked.
What version of php do you have? Maybe built-in OPcache is playing you tricks?

Quote from: Burke Knight – The BBC Move topic... http://www.elkarte.net/community/index.php?topic=1750.msg18572#msg18572
That one was a "slightly" different issue: http://www.elkarte.net/community/index.php?topic=1750.msg18590#msg18590
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 09, 2015, 04:09:18 am
Yes, but we had thought it could be the same, at the time... LOL
Current PHP version:  5.5

Funny thing is, it installs and works on some sites, but not others.
DeadMan's site, it would not show any of what entered into the boxes, and the Addon Demo site worked after a while.

Now, doing hooks, will that install into custom themes, the way it's coded?
I just thought of that. DeadMan's site is using Silence theme, and maybe the calls the addon looks for, are not present?

EDIT:

Looks like I may have found the issue,

Install the addon, and enter something into the copyright, but not the below linktree box, and tell me what happens.
Title: Re: Known Hook addons not working right
Post by: emanuele on July 09, 2015, 08:00:22 am
Indeed a bug... of the addon. :P

You are testing only global_mid, so if that is not inserted, nothing is shown.
You should split the "if" clock and for each one check if the corresponding setting is filled or not and add it to $gfh accordingly. ;)
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 09, 2015, 08:08:19 am
Don't forget, I do not know hooks... @ahrasis did that part for me. ;)

Fixed, and package replaced. :)
Title: Re: Known Hook addons not working right
Post by: emanuele on July 09, 2015, 08:37:26 am
That's not really about hooks. ;)

Don't be afraid of hooks, they do not bite!! :P
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 09, 2015, 08:43:15 am
No, but they can very hard to tell what the heck to do.... LOL
One look, and I'm so lost....
Title: Re: Known Hook addons not working right
Post by: ahrasis on July 09, 2015, 08:54:29 am
Buffer is like that can change BK to BurkeKnight so long BK can be found in that template. If BK is now BN in custom template, then you should change or add that into the subs file accordingly. We try to find unique elements and hook so that in won't disturb others.
Title: Re: Known Hook addons not working right
Post by: Burke Knight on July 09, 2015, 09:00:52 am
It was not that, it was the if for each had to be done.
Way it was, they all were in the same if.
Title: Re: Known Hook addons not working right
Post by: ahrasis on July 09, 2015, 09:07:05 am
Oh yes. The if. It should be unique for each $modsettings. Sorry about that. :)
Title: Re: Known Hook addons not working right
Post by: emanuele on July 09, 2015, 09:25:03 am
I'll try to give you a different way to look at them hooks.

In ElkArte code you see for example:
Code: [Select]
call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
You look at it because you want to add a new setting and you think WTH!

So, I'll tell you, when you see such function in the code, you can "translate" it to:
Code: [Select]
This_is_my_addond_function(&$config_vars);
This is what the code does. Really. That's all (for what matters *to you*).

A practical example.
In this addon you are adding settings, right?
And you do that with the function "GHF_Settings", correct?
So, in the install file of the addon, you have the string:
Code: [Select]
'integrate_general_mod_settings' => 'GHF_Settings|SOURCEDIR/addons/GHF.subs.php',
again, WTH?!?! :P

Let's translate it into an "English-like" thing.
In the code, where there is the
Code: [Select]
call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
line, ElkArte will do this:
Code: [Select]
require_once(SOURCEDIR . '/addons/GHF.subs.php');
GHF_Settings(&$config_vars);

If you look at the string in your install file, you see the three pieces:
Code: [Select]
'integrate_general_mod_settings'
Code: [Select]
'GHF_Settings
Code: [Select]
SOURCEDIR/addons/GHF.subs.php',

Dunno if it helps explaining them or just makes things more confused. LOL
Title: Re: Known Hook addons not working right
Post by: ahrasis on July 09, 2015, 10:44:26 am
It helps indeed. Those with strong php knowledge and experience will understand better. For me, I just try coding to make some sense from a copy paste. :D