Jump to content

[Free module] Featured Categories on HomePage


trio12

Recommended Posts

"Featured Categories on Home Page" module (hook 'displayHome'):

 

  • Header + additional description (multi-languages)
  • Displays images of the Categories
  • Dynamic counter of active products in the category
  • Counter of "selected categories"
  • Compatible with PrestaShop 1.7 - 8
  • Language versions: EN (PL and soon more languages...)

 

Screen:

image.thumb.png.50beae8a518f82b3e752d2f04a685fb6.png

===

image.png

mkd_categories_homepage.zip

Edited by trio12 (see edit history)
  • Like 1
  • Thanks 3
Link to comment
Share on other sites

  • 2 months later...

Hello,

It is not working for me PHP7.4 PS1.7.8.9

1/1) ContextErrorException

Notice: Undefined index: selectedCategoryCount

in 9e166e8a6f508d38b98e22ab2b721e608a127acf_2.file.categories_homepage.tpl.php line 36

at content_64fb2bb98a7b89_45491311(object(SmartyDevTemplate))in smarty_template_resource_base.php line 123

at Smarty_Template_Resource_Base->getRenderedTemplateCode(object(SmartyDevTemplate))in smarty_template_compiled.php line 114

at Smarty_Template_Compiled->render(object(SmartyDevTemplate))in smarty_internal_template.php line 216

at Smarty_Internal_Template->render(false, 0)in smarty_internal_templatebase.php line 232

at Smarty_Internal_TemplateBase->_execute(object(SmartyDevTemplate), null, null, null, 0)in smarty_internal_templatebase.php line 116

at Smarty_Internal_TemplateBase->fetch(null, null, null, null, false, true, false)in SmartyDevTemplate.php line 40

at SmartyDevTemplateCore->fetch()in Module.php line 2449

at ModuleCore->display('/var/www/vig/parts-shop/modules/mkd_categories_homepage/mkd_categories_homepage.php', 'views/templates/hook/categories_homepage.tpl')in mkd_categories_homepage.php line 180

at MKD_categories_homepage->hookDisplayHome(array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 1))in Hook.php line 1007

at HookCore::coreCallHook(object(MKD_categories_homepage), 'hookDisplayHome', array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 1))in Hook.php line 431

at HookCore::callHookOn(object(MKD_categories_homepage), 'displayHome', array('cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 1))in Hook.php line 944

at HookCore::exec('displayHome')in IndexController.php line 39

at IndexControllerCore->initContent()in Controller.php line 306

at ControllerCore->run()in Dispatcher.php line 525

at DispatcherCore->dispatch()in index.php line 28

Link to comment
Share on other sites

There are 2 possible solutions:
1. No category in the module has been selected
2. Or add a checking condition in the template (categories_homepage.tpl)

{if isset($selectedCategoryCount)}
     {foreach $selectedCategories as $category}
         ....
     {/foreach}
{/if}

 

Edited by trio12 (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 11 months later...

Not working properly in my PS 8.1.5

It looks like it's conflicting with other modules. I got this when opening the module configuration page:

 

Unknown error at line 30 in file .../modules/mkd_categories_homepage/mkd_categories_homepage.php
[8192] Creation of dynamic property MKD_categories_homepage::$image is deprecated

Unknown error at line 53 in file .../modules/myprestacomments/myprestacomments.php
[8192] Creation of dynamic property myprestacomments::$mypresta_link is deprecated

Unknown error at line 59 in file .../modules/myprestacomments/myprestacomments.php
[8192] Creation of dynamic property myprestacomments::$secure_key is deprecated

Unknown error at line 1452 in file .../modules/myprestacomments/myprestacomments.php
[8192] Creation of dynamic property myprestacomments::$mkey is deprecated

Unknown error at line 356 in file .../modules/mkd_categories_homepage/mkd_categories_homepage.php
[8192] Creation of dynamic property MKD_categories_homepage::$fields_form is deprecated

Unknown error at line 46 in file .../modules/ybc_themeconfig/ybc_themeconfig.php
[8192] Creation of dynamic property Ybc_themeconfig::$secure_key is deprecated

Unknown error at line 21 in file .../modules/ybc_manufacturer/ybc_manufacturer.php
[8192] Creation of dynamic property Ybc_manufacturer::$secure_key is deprecated

Unknown error at line 38 in file .../modules/ets_multilayerslider/ets_multilayerslider.php
[8192] Creation of dynamic property Ets_multilayerslider::$secure_key is deprecated

Unknown error at line 41 in file .../modules/ets_megamenu/ets_megamenu.php
[8192] Creation of dynamic property Ets_megamenu::$secure_key is deprecated

Unknown error at line 45 in file .../modules/ets_reviewticker/ets_reviewticker.php
[8192] Creation of dynamic property Ets_reviewticker::$secure_key is deprecated

Unknown error at line 51 in file .../modules/ets_mailchimpsync/ets_mailchimpsync.php
[8192] Creation of dynamic property Ets_mailchimpsync::$key is deprecated

Unknown error at line 55 in file .../modules/ets_purchasetogether/ets_purchasetogether.php
[8192] Creation of dynamic property Ets_purchasetogether::$secure_key is deprecated

Unknown error at line 4116 in file .../var/cache/dev/ContainerKpOkqWx/appAppKernelDevDebugContainer.php
[8192] Creation of dynamic property PrestaShopBundle\Twig\ContextIsoCodeProviderExtension::$logger is deprecated

Unknown error at line 4117 in file .../var/cache/dev/ContainerKpOkqWx/appAppKernelDevDebugContainer.php
[8192] Creation of dynamic property PrestaShopBundle\Twig\ContextIsoCodeProviderExtension::$translator is deprecated

Unknown error at line 54 in file .../modules/ets_wishlist_pres17/ets_wishlist_pres17.php
[8192] Creation of dynamic property Ets_wishlist_pres17::$refs is deprecated

Unknown error at line 77 in file .../modules/ybc_widget/ybc_widget.php
[8192] Creation of dynamic property Ybc_widget::$secure_key is deprecated

Unknown error at line 49 in file .../modules/ets_htmlbox/ets_htmlbox.php
[8192] Creation of dynamic property Ets_htmlbox::$refs is deprecated

 

And the categories in home are all messed up and returning this:

.../var/cache/dev/smarty/compile/amazonas/f0/07/ac/f007ac38729a798c172faa122655b4a1d03a2005_2.file.categories_homepage.tpl.php on line 36

Warning: Attempt to read property "value" on null in .../var/cache/dev/smarty/compile/amazonas/f0/07/ac/f007ac38729a798c172faa122655b4a1d03a2005_2.file.categories_homepage.tpl.php on line 36

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

You need to remove/edit conditional classes (use Bootstrap grid) in:".../views/templates/hook/categories_homepage.tpl"

...
<div class="row">
  {foreach $selectedCategories as $category}
    <div class="{if $selectedCategoryCount>=4 }col-xs-3{else}col-xs-6{/if}" style="margin: 0 auto;text-align:center; min-heihgt: 300px;">.....</div>
...
</div>

... you can also display "$category.description" [remove comment mark {****.........***} around]

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

any way to order the categories so that they appear alphabetically?

Figured it out:

in mkd_categories_homepage.php change this code:                     

  $categoryData = array(

                            'id' => $category->id,
                            'name' => $category->name,
                            'url' => $category->getLink(),
                            'imagePath' => _THEME_CAT_DIR_ . $category->getLinkRewrite($category->id, $currentLangCode) . $category->id . '.jpg',                       
                            'description' => $category->description,
                            'productCount' => $productCount
                        );

to this:

                        $categoryData = array(
                            'name' => $category->name,
                            'id' => $category->id,
                            'url' => $category->getLink(),
                            'imagePath' => _THEME_CAT_DIR_ . $category->getLinkRewrite($category->id, $currentLangCode) . $category->id . '.jpg',                       
                            'description' => $category->description,
                            'productCount' => $productCount
                        );

and just before the following code:

       

$this->context->smarty->assign(array(
            'selectedCategories' => isset($selectedCategories) ? $selectedCategories : array(),
            'title' => isset($title) ? $title : '',
            'legend' => isset($legend) ? $legend : '',
        ));

in mkd_categories_homepage.php add

     

  sort($selectedCategories);

This sorts the array alphabetically.
        

Edited by tommcmur
updated to include file name (see edit history)
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...