News:

AbanteCart v1.4.2 is released.

Main Menu
support

Hook Category Block Controller

Started by yonghan, October 24, 2014, 08:05:24 AM

Previous topic - Next topic

yonghan

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.

abolabo

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

Hello abolaboi,i have able to hook public functions without problem but seems it doesn't work with private functions.

abolabo

Quote from: handoyo 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.

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

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


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

R19Tono

I am also not able to display categories in Categories block.

Can someone throw some light on this issue?

Thanks
1fatp8uh3k5159596

Forum Rules Code of conduct
AbanteCart.com 2010 -