Author Topic: Hook Category Block Controller  (Read 5934 times)

yonghan

  • Guest
Hook Category Block Controller
« on: October 24, 2014, 08:05:24 AM »
Hi admins,i'm trying to extend the Category Block Controller without editing the core file,the function i want to override is the private functions.Is it possible to do that?Thanks a lot.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1754
  • Karma: +243/-11
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Hook Category Block Controller
« Reply #1 on: October 24, 2014, 08:37:51 AM »
Hello.
You can look into file public_html/extensions/default_pp_pro/core/default_pp_pro.php to see how hook works.
More details here http://www.abantecart.com/document_wiki/index.php/AbanteCart_Extension%E2%80%99s_Developer_Guide#Hooks

we recommends to use our developer tools extension.
You can download and install developer tools and generate new extension with prebuilded files.
https://github.com/abantecart/developer_tools_extension
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

yonghan

  • Guest
Re: Hook Category Block Controller
« Reply #2 on: October 24, 2014, 09:03:17 AM »
Hello abolaboi,i have able to hook public functions without problem but seems it doesn't work with private functions.

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1754
  • Karma: +243/-11
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Hook Category Block Controller
« Reply #3 on: October 24, 2014, 09:14:51 AM »
Hello abolaboi,i have able to hook public functions without problem but seems it doesn't work with private functions.

sure. You can't to hook private methods. You should to change it's output.

Also you can get variables from "view" via $this->baseobject->view->getData('some var name'); inside  _initUpdate() hook and rewrite it
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

yonghan

  • Guest
Re: Hook Category Block Controller
« Reply #4 on: October 24, 2014, 09:20:29 AM »
Hi abolabo,i have found the way to do what i'm trying to do without modifying the core file or hook it.Actually what i want to achieve is to display the 2nd level child in category_top block.Here is what i have done in case someone want to use it too.I just edit the https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/view/default_html5/template/blocks/category_top.tpl and add this code after line 36.

Code: [Select]
<?php
                                        $cat
=$scat['children'];
                                        foreach (
$cat as $ct) { ?>

                                        <li><a href="<?php echo $ct['href']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $ct['name'];?></a>
                                            <img class="sub_cat_image" style="display:none" src="<?php echo $ct['thumb']; ?>"
                                                 alt="<?php echo $ct['name']; ?>"
                                                 title="<?php echo $ct['name']; ?>">
                                        </li>
                                        <?php ?>


Thanks a lot.By the way please help me to take a look at my thread too regarding extension update script if you don't mind and have the time too.
« Last Edit: October 25, 2014, 06:24:27 AM by handoyo »

Offline R19Tono

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Hook Category Block Controller
« Reply #5 on: December 11, 2014, 07:06:50 PM »
I am also not able to display categories in Categories block.

Can someone throw some light on this issue?

Thanks