Welcome Guest, Not a member yet? Register   Sign In
Using Hooks - "display_override" is called twice?
#1

[eluser]andreliem[/eluser]
I'm trying to have some code run after an action has completed by using the hook for display_override.

For some reason it is being called twice when I think it should only be called once.

Any ideas why this might be?
#2

[eluser]andreliem[/eluser]
Oh I think I figured it out. Setting the function to be called as "__construct" was the reason. I could see that being an issue when I think of it now.
#3

[eluser]sweetD[/eluser]
Hate to resurrect this but I'm having a similar issue where it's out putting the values twice. the function value is "__construct" if I remove the function key and value, it's still outputting twice. If i choose specific method it does not work at all.
#4

[eluser]vitoco[/eluser]
Post the hook and display code
#5

[eluser]sweetD[/eluser]
I ended up figuring it out,

When you load the hook if it's a class it will load the __constructor, twice if your function is set to '__constructor' in your hooks.php.

So what I did is, create an empty function called empty and the sent function = 'empty', which just returns with return; and my __constructor is loaded once.
#6

[eluser]vitoco[/eluser]
why put the logic of the display hook inside the __construct function ??, for what i understand, that's the initialization function, to set some variables, load some class wide libraries/models/helpers and nothing more. The problem, if you wanna add another function that do something other than display content, you will also do that automatically ( and before what you really wanna do ) because __construct gets called EVERY TIME that the class gets instantiated.




Theme © iAndrew 2016 - Forum software by © MyBB