Menu Close
    Start a Project Request quote Reading list Switch to dark mode
    prestashop-hyperlocal-marketplace-guide

    Adding Breadcrumb in PrestaShop 1.7 Module Front Controller

    Add Breadcrumb in PrestaShop 1.7 Module Front Controller By a function :

    PrestaShop 1.7 has been released early and there are many changes from code end like Symfony introduced and the default theme is updated to a new classic theme.

    If you are developing Module for PrestaShop 1.7. This version introduced a new way of managing the Breadcrumbs on every page. In V1.6, we were managing breadcrumbs on tpl page but now we can manage this by a php function.

    You are just needed to add this PHP function in your module front controller, You can see then the breadcrumbs in your front page.

     


    Initial Prestashop versions is not translating the string written in trans() function for non-native modules. You can use

    $this->module->l(‘Women’, ‘controller_name’)

    instead of this.

    Finally, Breadcrumb will look like this,

    . . .

    Comments (5)

    Add Your Comment

  • Deleval Denis
    Hi Dheeraj,
    Thanks for your help !
    Denis
  • Deleval Denis
    Hi Dheeraj,

    I was looking for changing the breadcrumb in my module. I followed your tip but it didn’t work on PS 1.7.2.0:
    I pasted your code into
    class MyModuleManageModuleFrontController extends ModuleFrontController
    {

    #yourcode

    }
    But on Front end I cannot see the default breadcrumb. Perhaps I missed something …

    However I’ve tried out with success this method:
    class MyModuleManageModuleFrontController extends ModuleFrontController
    {
    public function initContent()
    {
    parent::initContent();
    $this->assign();
    }

    /**
    * Assign manage list template
    */
    public function assign()
    {

    $links[] = array(
    ‘title’ => ‘ex1’,
    ‘url’ => $link->getPageLink(‘my-account’, true)
    );
    $links[] = array(
    ‘title’ => ‘ex2’,
    ‘url’ => ‘another url’
    );
    $links[] = array(
    ‘title’ => ‘ex3’,
    ‘url’ => ”
    );

    $context->smarty->assign(‘breadcrumb’, array(‘count’ => count($links), ‘links’ => $links));
    }
    }

    • Dheeraj Sharma
      getBreadcrumbLinks() this is not my function, this prestashop default function. I have overrided this and add my own breadcrumb.

      Do not use your own assign() function just override getBreadcrumbLinks() function and write your code in this function.

      Correct code;
      public function getBreadcrumbLinks()
      {
      $breadcrumb = parent::getBreadcrumbLinks();

      $breadcrumb[‘links’][] = [
      ‘title’ => $this->getTranslator()->trans(‘ex1’, [], ‘Breadcrumb’),
      ‘url’ => $this->context->link->getPageLink(‘my-account’, true)
      ];

      $breadcrumb[‘links’][] = [
      ‘title’ => $this->getTranslator()->trans(‘ex2’, [], ‘Breadcrumb’),
      ‘url’ => ‘another url’
      ];

      $breadcrumb[‘links’][] = [
      ‘title’ => $this->getTranslator()->trans(‘ex3’, [], ‘Breadcrumb’),
      ‘url’ => ”
      ];

      return $breadcrumb;
      }

      Remove $this->assign(); from initContent();

  • Zyfraglover
    Thank’s for the tip! very usefull and way better than TPL’s imo :)à
    • Dheeraj Sharma
      Thanks @zyfraglover:disqus
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close