Page 1 of 1

cutting off product name from breadcrumb on product page

Posted: Wed Aug 21, 2019 9:48 pm
by aerogel
hi
im using OC 3.0.2.0. most of my products has a very long name and i need to have the last piece of breadcrumbs in "product page" to be cut off.
any suggestion plz.
thanks.

Re: cutting off product name from breadcrumb

Posted: Wed Aug 21, 2019 11:19 pm
by thekrotek
You can add mb_substr() function to every controller, which uses breadcrumbs, and cut the breadcrumbs text by given value.

Re: cutting off product name from breadcrumb

Posted: Thu Aug 22, 2019 12:41 am
by aerogel
i found something working here for OC 2
viewtopic.php?t=175516

this is the block of code in my product.twig that generates the breadcrumb

Code: Select all

  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
    <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% 
    endfor %}
  </ul>
they managed some how to edit the OC2's code to cut off the product name. im looking for smth like that. (above link)

Re: cutting off product name from breadcrumb

Posted: Thu Aug 22, 2019 12:53 am
by thekrotek
You cut it in CONTROLLER, not in template.

Re: cutting off product name from breadcrumb

Posted: Thu Aug 22, 2019 12:56 am
by aerogel
thekrotek wrote:
Thu Aug 22, 2019 12:53 am
You cut it in CONTROLLER, not in template.
i dont know how!

Re: cutting off product name from breadcrumb

Posted: Thu Aug 22, 2019 1:02 am
by thekrotek
sedra wrote:
Thu Aug 22, 2019 12:56 am
i dont know how!
If you don't have enough coding skills, you can always request a commercial support.

Re: cutting off product name from breadcrumb on product page

Posted: Thu Aug 22, 2019 1:36 am
by xxvirusxx
You can remove this from catalog/controller/product/product.php (line 212)

Code: Select all

$data['breadcrumbs'][] = array(
	'text' => $product_info['name'],
	'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
);
or from product.twig this code, to remove entire breadcrumb

Code: Select all

  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %}
    <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %}
  </ul>

Choose how you like.

Re: cutting off product name from breadcrumb on product page

Posted: Thu Aug 22, 2019 6:32 pm
by paulfeakins
Or a pure CSS solution:

Code: Select all

.breadcrumb li a {
    line-height: 1em;
    max-width: 61px;
    overflow: hidden;
    display: inline-block;
}
Image

Re: cutting off product name from breadcrumb on product page

Posted: Thu Aug 22, 2019 9:17 pm
by thekrotek
paulfeakins wrote:
Thu Aug 22, 2019 6:32 pm
Or a pure CSS solution:

Code: Select all

.breadcrumb li a {
    line-height: 1em;
    max-width: 61px;
    overflow: hidden;
    display: inline-block;
}
Image
With this you won't be able to add nice three dot ellipsis in the end :-)

Re: cutting off product name from breadcrumb on product page

Posted: Fri Aug 23, 2019 5:19 pm
by aerogel
thank you all for your "non commercial" support!
here i admit that i used to be a software developer for sometime and i know how it feels to make a living with 10 hours and more F5-ing and debugging line by line in front of a monitor and of course i appreciate their work.
but
there are many thing beside making money that matters.
(this is my campaign slogan when I'm running for the office!)
so excited to test your suggestions one by one.

Re: cutting off product name from breadcrumb on product page

Posted: Fri Aug 23, 2019 5:39 pm
by aerogel
xxvirusxx wrote:
Thu Aug 22, 2019 1:36 am
You can remove this from catalog/controller/product/product.php (line 212)

Code: Select all

$data['breadcrumbs'][] = array(
	'text' => $product_info['name'],
	'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
);
from now on
i have a different mindset about a "VIRUS".
thanks a lot.

Re: cutting off product name from breadcrumb on product page

Posted: Fri Aug 23, 2019 9:20 pm
by cyclops12
sedra wrote:
Fri Aug 23, 2019 5:39 pm
from now on
i have a different mindset about a "VIRUS".
thanks a lot.
😂😂😂😂

Re: cutting off product name from breadcrumb on product page

Posted: Fri Aug 23, 2019 10:02 pm
by letxobnav

Code: Select all

$data['breadcrumbs'][] = array(
	'text' => mb_substr($product_info['name'], 0, strrpos(mb_substr($product_info['name'], 0, 60), ' ' )).'...',
	'href' => $this->url->link('product/product', $url . '&product_id=' . $this->request->get['product_id'])
);
this will break off the name after 60 characters and then cut it on the last space so it does not cut it inside a word.

Re: cutting off product name from breadcrumb on product page

Posted: Sat Apr 11, 2020 2:51 pm
by nightwing
You can use this free module to remove breadcrumb completely from all mobile devices:
viewtopic.php?f=183&t=217081
OCMod Installation

Re: cutting off product name from breadcrumb on product page

Posted: Sat Apr 11, 2020 4:16 pm
by letxobnav
you thought "let's bring back a vital topic from 8 months ago".

Re: cutting off product name from breadcrumb on product page

Posted: Sat Apr 11, 2020 9:20 pm
by nightwing
Well, I was having this problem, so I was reading through, instead of creating a new post, I just commented to help any version, 3 users, with an easy solution.
letxobnav wrote:
Sat Apr 11, 2020 4:16 pm
you thought "let's bring back a vital topic from 8 months ago".