Jump to content
thirty bees forum
  • 0

Adding a new content hook to homepage.


urban

Question

Hey guys. I'm trying to add a new htmlblock hook to BELOW  the image slider and above featured products on the niara theme homepage. I've spent 2 days trying out and putting echo exit breaks on checkpoints to see where and what i'm outputting, but to no avail.

What i've done so far is

1. add a new entry to the tb_hooks section and calling it displayHomeStaticContent

2. inside tbhtmlblock.php i've modified 

        // List of hooks
      $this->hooksList = [
                ...
            'displayHomeTabContent',
            'displayHomeStaticHTML',
];


#line 537
    public function hookDisplayHomeStaticHTML($params)
    {
        return $this->hookCommon('displayHomeStaticHTML', $params);
    }

3. at front/IndexController.php i've modified 

        $this->context->smarty->assign(
            [
                'HOOK_HOME'             => Hook::exec('displayHome'),
                'HOOK_HOME_TAB'         => Hook::exec('displayHomeTab'),
                'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent'),
// NEW HOOK ENTRY HERE
                'HOOK_HOME_STATIC_HTML'         => Hook::exec('displayHomeStaticHTML'),

            ]
        );

4. finally at themes/niara/index.tpl i've adjusted

{if !empty($HOOK_HOME_STATIC_HTML)}
  <div class="tab-content">
    {$HOOK_HOME_STATIC_HTML}
  </div>
{/if}

{* the rest of the index code below the image slider}

I've put in a lot echos inside the relevant function code areas, and I've found out that 

Hook::exec('displayHomeStaticHTML') is being called but is not triggering the PHP function, and that 

public function hookDisplayHomeStaticHTML($params) isn't being called also

 

What am I missing or doing wrong, in trying to create a new hook,solely to be used on the homepage only?

 

Thanks for all your help!

Alan

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Also, get rid of step #3, and call the hook directly from the theme. Never update the core files. 

  <div class="tab-content">
    {hook h='displayHomeStaticHTML'}
  </div>

If you need the conditional, then you can do that with capture

{capture name='homeStaticContent'}{hook h='displayHomeStaticHTML'}{/capture}  
{if !empty($smarty.capture.homeStaticContent)} 
  <div class="tab-content">
    {$smarty.capture.homeStaticContent}
  </div>
{/if}

 

Link to comment
Share on other sites

  • 0

Ah! I haven't datakick! Thank you for your reply!

 

I go about and see how to reset the php. Should be able to figure out that part.

 

Acknowledged about step 3. I'll revert the core file back.

 

 

 

Thank you for helping me out 🙂

Alan

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...