Jump to content

Remove product title from breadcrumb


Recommended Posts

Try changing line 641 of classes/Tools.php from:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true).''.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8').'';



to:

return self::getPath($id_category, Category::hideCategoryPosition($category->name), true)/*.''.$pipe.' '.htmlentities($end, ENT_NOQUOTES, 'UTF-8').''*/;

Link to comment
Share on other sites

  • 8 months later...

Hi rocky,

I tried to change my breadcrumb using your method on prestashop 1.4.1.0 but it doesn't work.

before:

        return self::getPath($id_category, $category->name, true, $type_cat).''.$pipe.' 
class="navigation_product">'.htmlentities($end, ENT_NOQUOTES, 'UTF-8').'';




after :

        return self::getPath($id_category, $category->name, true, $type_cat)/*.''.$pipe.' 
class="navigation_product">'.htmlentities($end, ENT_NOQUOTES, 'UTF-8').''*/;



Do you have an idea, how to do it ?


Chris

Link to comment
Share on other sites

  • 2 months later...

I'd like to figure this one out, too. Will report back when I find the solution.

We're working on a shop with long category and product names, and I find that having the product name in the breadcrumb is redundant, especially when it's displayed again, just beneath the breadcrumb.

Link to comment
Share on other sites

The following instructions apply to PrestaShop 1.4.3.

They have not been tested thoroughly, so there may be unknown side effects to making the following change - I will report back if I come across any negative side-effects.

In Tools.php, change line 818 ( in function getPath() ) from this:

return $fullPath.$path;



To this:

return $fullPath;



Note: You'll end up with a trailing category pipe at the end of the breadcrumb.

Note: For safety and upgrade reasons, you should use the /override/classes/ method for overriding / extending the original ToolsCore class.

Link to comment
Share on other sites

Simply replace following line in controller->productController.php in prestashop v1.4+
and in product.php in lower version


Vivek, thanks for the help, but I think my method is better, since my change is localized to the code that's responsible for building the breadcrumb, whereas yours would affect any and all functions that rely on 'path'.

Changes should be as localized as possible to minimize unwanted side-effects.

Kurt

Edit: I retract my statement that my method is necessarily better than Vivek's. Tools::getPath() is called from three files in my PrestaShop 1.4.3 installation (CategoryController.php, ProductController.php, CMSController.php). My change will only affect the call from ProductController.php, due to the way the function is defined and how it is called from the other locations.

However, it's possible that another PrestaShop configuration with additional or modified Controllers or with a different set of Modules could call Tools::getPath() and run into problems due to the change I suggested (possible, but I think highly unlikely, since Tools::getPath() creates an html string that's not likely to be used in any kind of calculation, query or appplication logic).

I'll switch to Vivek's method and report back if I come across any problems with it.
Link to comment
Share on other sites

Hi xioup

its good alternative to remove title from bredcumb
since query is for product page and user simply want to remove from product page
so I would preffer to change should be localised i.e. in product.php
insted of change core class file Tool.php. I found that Tools::getpath function used at several places .
it may effect others too.

However its good alternative. thanks for suggestion and new method

Link to comment
Share on other sites

  • 1 month later...
  • 2 years later...
  • 2 months later...

In prestashop v.1.6.0.9 copy /controllers/front/ProductController.php to /override/controllers/front/ and replace line 578 in /override/controllers/front/ProductController.php

$path = Tools::getPath($this->category->id, $this->product->name, true);

with the code

$path = Tools::getPath($this->category->id, ' ', true);

 

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

To remove the categories title you have to go to themes/category.tpl

 

 <h1 class="page-heading{if (isset($subcategories) && !$products) || (isset($subcategories) && $products) || !isset($subcategories) && $products} product-listing{/if}">{$category->name|escape:'html':'UTF-8'}{if isset($categoryNameComplement)} {$categoryNameComplement|escape:'html':'UTF-8'}{/if}
        {include file="$tpl_dir./category-count.tpl"}
    </h1>
 
Find these line in your themes and remove these lines . 
Link to comment
Share on other sites

  • 1 year later...
  • 2 weeks later...

If you already have an /override/controllers/front/ProductController.php file (my shop does because of my theme) then you can do something like the following:

my original theme override ProductController.php looks like:

 

class ProductController extends ProductControllerCore
{
    /*
    * module: stoverride
    * date: 2016-03-01 21:21:12
    * version: 1.0
    */
    public function initContent()
    {
        parent::initContent();
        if(Configuration::get('STSN_PRODUCT_SECONDARY'))
            $this->context->smarty->assign(array(   
                'HOOK_PRODUCT_SECONDARY_COLUMN' => Hook::exec('displayProductSecondaryColumn'),     
            ));
    }
}
Before the last } in the file insert the category template vars code:
 
class ProductController extends ProductControllerCore
{
    /*
    * module: stoverride
    * date: 2016-03-01 21:21:12
    * version: 1.0
    */
    public function initContent()
    {
        parent::initContent();
        if(Configuration::get('STSN_PRODUCT_SECONDARY'))
            $this->context->smarty->assign(array(   
                'HOOK_PRODUCT_SECONDARY_COLUMN' => Hook::exec('displayProductSecondaryColumn'),     
            ));
    }

    /**
     * Assign template vars related to category
     */
    protected function assignCategory()
    {
        // Assign category to the template
        if ($this->category !== false && Validate::isLoadedObject($this->category) && $this->category->inShop() && $this->category->isAssociatedToShop()) {
            /* remove product name from breadcrumb */
            //$path = Tools::getPath($this->category->id, $this->product->name, true);
            $path = Tools::getPath($this->category->id, '', true);
        } elseif (Category::inShopStatic($this->product->id_category_default, $this->context->shop)) {
            $this->category = new Category((int)$this->product->id_category_default, (int)$this->context->language->id);
            if (Validate::isLoadedObject($this->category) && $this->category->active && $this->category->isAssociatedToShop()) {
                $path = Tools::getPath((int)$this->product->id_category_default, $this->product->name);
            }
        }
        if (!isset($path) || !$path) {
            $path = Tools::getPath((int)$this->context->shop->id_category, $this->product->name);
        }

        $sub_categories = array();
        if (Validate::isLoadedObject($this->category)) {
            $sub_categories = $this->category->getSubCategories($this->context->language->id, true);

            // various assignements before Hook::exec
            $this->context->smarty->assign(array(
                'path' => $path,
                'category' => $this->category,
                'subCategories' => $sub_categories,
                'id_category_current' => (int)$this->category->id,
                'id_category_parent' => (int)$this->category->id_parent,
                'return_category_name' => Tools::safeOutput($this->category->getFieldByLang('name')),
                'categories' => Category::getHomeCategories($this->context->language->id, true, (int)$this->context->shop->id)
            ));
        }
        $this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category))));
    }

}

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

  • 3 years later...
On 10/30/2014 at 8:14 PM, makler3d said:

In prestashop v.1.6.0.9 copy /controllers/front/ProductController.php to /override/controllers/front/ and replace line 578 in /override/controllers/front/ProductController.php


$path = Tools::getPath($this->category->id, $this->product->name, true);

with the code


$path = Tools::getPath($this->category->id, ' ', true);

 

Thanks, it works - but how do I get rid of the last arrow after the category name?

Home > Cat 1 > Cat2 > 

 

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