Jump to content

[Solved] Custom hook won't show


Recommended Posts

Hi everyone,

 

I'm trying to create a new hook to place a module on a page, but I can't get it to work.

It's on my contact form, I want to replace this form by the module webcallback.

 

In my webcalback.php I added my new hook in the same way as the old one in my install function

!$this->registerHook('leftColumn') || !$this->registerHook('footer') || !$this->registerHook('hookPersoContact')

And I also added this function ( which is the same as the hookRightColumn() and hookLeftColumn() for example )

public function hookPersoContact()
{
    return ($this->displayBlock());
}

In my contact-form.tpl I added at the beginning of my file the declaration of the hook, which now appears in the database. The print tests work fine.

<p>Print test 1</p>
{hook h='hookPersoContact'}
<p>Print test 2</p>

So, with all this, my hook appears in my back-office in the Modules->Position tab, I can hook my module to it, but it doesn't display. Also, it's considered as an invisible hook.

 

I tried to change the name of my hook to displayhookPersoContact, the only effect it had was that it was no longer considered as invisible in Modules->Position. I also edited my hookPersoContact() function as this so it looks like my hookFooter() and hookTop() functions.

public function hookPersoContact()
{
return ($this->displayBlock('hookPersoContact'));
}

Didn't work either.

 

I didn't get why Top and Footer have to use parameters for displayBlock() while left/rightColumn don't, and why in my install function doing registerHook('leftColumn') leads to a hook called displayLeftColumn so that's why I tried the above things.

 

Any help would be appreciated at this point. Thanks in advance.

 

Edited by Xuân (see edit history)
Link to comment
Share on other sites

Hey,

 

Sorry, some really awesome guy already helped me on a French topic. He rocks :P

 

So for those who want the solution : 

In the function install, you have to put display before the name of the hook, so : 

!$this->registerHook('displayPersoContact')

In the function in the php file ( webcallback.php for me e.g. ), you have to put hookDisplay before the name of the hook, so :

public function hookDisplayPersoContact(){...}

In the .tpl, you have to put display before the name of the hook, so :

{hook h='displayPersoContact'}

It worked for me. It might be easier to do, see what anteverce suggests, but I didn't make it work with just {hook h='PersoContact'} so I prefer to give an option that works as far as I know.

Thanks for not helping, english community <3

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...