How to Create Breadcrumb in PrestaShop 1.7?
The Breadcrumb allows a user to maintain the location on the websites. One can easily create the Breadcrumb on the Prestashop.
Introduction
The Breadcrumb allows a user to maintain the location on the websites. One can easily create the Breadcrumb on the Prestashop. If you are creating a module which has a separate page on the front then you would create a front controller by extending the ModuleFrontController file and this ModuleFrontController file extends FrontController which has the following function:
protected function getBreadcrumbLinks()
{
$breadcrumb = array();
$breadcrumb['links'][] = array(
'title' => $this->getTranslator()->trans('Home', array(), 'Shop.Theme.Global'),
'url' => $this->context->link->getPageLink('index', true),
);
return $breadcrumb;
}How to Add?
Now, To create the Breadcrumb for your page you just have to create the same function in your front controller (Which you must have created by extending the ModuleFrontController) and append your Breadcrumb title and link with the parent Breadcrumb. Please look into the following code to understand it better:
protected function getBreadcrumbLinks()
{
$breadcrumb = parent::getBreadcrumbLinks(); /* Get the Breadcrumb array from the parent function which is situated in the FrontController.php */
$breadcrumb['links'][] = array(
'title' => $this->module->l('level1', 'Current_controller_name') , /* Title which you want to give to the location */
'url' => $this->context->link->getModuleLink('module_name', 'Current_controller_name', array() , (bool)Configuration::get('PS_SSL_ENABLED')) , /* URL which you want to provide for a location */
);
$breadcrumb['links'][] = array(
'title' => $this->module->l('level2', 'Current_controller_name') , /* Title which you want to give to the location */
'url' => $this->context->link->getModuleLink('module_name', 'Current_controller_name', array() , (bool)Configuration::get('PS_SSL_ENABLED')) , /* URL which you want to provide for a location */
);
$breadcrumb['links'][] = array(
'title' => $this->module->l('level3', 'Current_controller_name') , /* Title which you want to give to the location */
'url' => $this->context->link->getModuleLink('module_name', 'Current_controller_name', array() , (bool)Configuration::get('PS_SSL_ENABLED')) , /* URL which you want to provide for a location */
);
return $breadcrumb;
}How it will look like on your page?
You have to add the above-mentioned function in the front controller you created. After adding the above code in the Front Controller, the Breadcrumb will be shown on the front page like below screenshot:
Bonus Tip:
If you want to make some changes (Like remove) in the Breadcrumbs then you can do the same using the following file:
/themes/classic/templates/_partials/breadcrumb.tpl
- PrestaShop Security in the AI Era: What Are Your Concerns?
- Managing Database Changes During Module Updates in PrestaShop
- Using PrestaShop Hooks Effectively in Your Module Development
- One Page Super Checkout: A Simple Way to Reduce Abandonment and Increase Sales
- Prestashop Advance Wishlist Addon- Get It Before 2026