MichaelEZ Posted October 17, 2019 Posted October 17, 2019 Hi, i would like to remove product name from breadcrumb on product pages.
0 wakabayashi Posted October 17, 2019 Posted October 17, 2019 You need to override the function assignCategory() in ProductController.php Change $path = Tools::getPath($this->category->id, $this->product->name, true); to $path = Tools::getPath($this->category->id, '', false); 1 1
0 DarkHorse Posted February 16, 2022 Posted February 16, 2022 On 10/17/2019 at 7:33 AM, wakabayashi said: You need to override the function assignCategory() in ProductController.php Change $path = Tools::getPath($this->category->id, $this->product->name, true); to $path = Tools::getPath($this->category->id, '', false); While this technique worked in PS 1.6.x for me, it does not work in my configuration of TB 1.3.0 and Panda 1.5.5. Using the Panda 1.5.5 Theme - this caused a different behavior; the breadcrumb had the correct text, but the last category "breadcrumb" displayed contained the url to the product page instead of the category. After digging through Tools.php and productController.php, it dawned on me that the last breadcrumb was being modified somewhere else... enter /themes/panda/breadcrumb.tpl I am including the entire code section so you can see what I commented out. I'm currently pressed for time in this migration effort, so eventually I will come back and clean this up a bit more (beginning line is ~28): {if !empty($path)} {* Extract bradcrumb links from anchors *} {$matchCount = preg_match_all('/<a.+?href="(.+?)"[^>]*>([^<]*)<\/a>/', $path, $matches)} {$breadcrumbs = []} {for $i=0; $i<$matchCount; $i++} {$breadcrumbs[] = ['url' => $matches[1][$i], 'title' => $matches[2][$i]]} {/for} {* Extract the last breadcrumb which is not link, it's plain text or text inside span *} {* $match = preg_match("/>([^<]+)(?:(?:<\/\w+>)*\s*)?$/", $path, $matches) *} {* if !empty($matches[1]) *} {* $breadcrumbs[] = ['url' => '', 'title' => $matches[1]] *} {* elseif !$match && !$matchCount *} {* $breadcrumbs[] = ['url' => '', 'title' => $path] *} {* /if *} {/if} By removing the "Extract the last breadcrumb..." code block, the entire product name and the associated link that was getting added to the last item in the breadcrumb is now removed with no other modifications necessary in the code or the overrides. Hope this helps somebody else out!
0 x97wehner Posted August 15, 2022 Posted August 15, 2022 On 2/16/2022 at 11:31 AM, DarkHorse said: While this technique worked in PS 1.6.x for me, it does not work in my configuration of TB 1.3.0 and Panda 1.5.5. Using the Panda 1.5.5 Theme - this caused a different behavior; the breadcrumb had the correct text, but the last category "breadcrumb" displayed contained the url to the product page instead of the category. After digging through Tools.php and productController.php, it dawned on me that the last breadcrumb was being modified somewhere else... enter /themes/panda/breadcrumb.tpl I am including the entire code section so you can see what I commented out. I'm currently pressed for time in this migration effort, so eventually I will come back and clean this up a bit more (beginning line is ~28): {if !empty($path)} {* Extract bradcrumb links from anchors *} {$matchCount = preg_match_all('/<a.+?href="(.+?)"[^>]*>([^<]*)<\/a>/', $path, $matches)} {$breadcrumbs = []} {for $i=0; $i<$matchCount; $i++} {$breadcrumbs[] = ['url' => $matches[1][$i], 'title' => $matches[2][$i]]} {/for} {* Extract the last breadcrumb which is not link, it's plain text or text inside span *} {* $match = preg_match("/>([^<]+)(?:(?:<\/\w+>)*\s*)?$/", $path, $matches) *} {* if !empty($matches[1]) *} {* $breadcrumbs[] = ['url' => '', 'title' => $matches[1]] *} {* elseif !$match && !$matchCount *} {* $breadcrumbs[] = ['url' => '', 'title' => $path] *} {* /if *} {/if} By removing the "Extract the last breadcrumb..." code block, the entire product name and the associated link that was getting added to the last item in the breadcrumb is now removed with no other modifications necessary in the code or the overrides. Hope this helps somebody else out! Just found this post. I'm curious, were you able to get rid of the last "after" navigation arrow as well? I followed your directive and it did remove the product correctly, but it left the last arrow. Thanks. 1
0 DarkHorse Posted September 12 Posted September 12 (edited) On 8/14/2022 at 10:39 PM, x97wehner said: Just found this post. I'm curious, were you able to get rid of the last "after" navigation arrow as well? I followed your directive and it did remove the product correctly, but it left the last arrow. Thanks. ^^ Just use wakabayashi's code above ^^ For those who might run across this after TB 1.3.0 Edited September 12 by DarkHorse 1
0 wakabayashi Posted September 13 Posted September 13 15 hours ago, DarkHorse said: ^^ Just use wakabayashi's code above ^^ Sounds clever 😅 👍 1 1
Question
MichaelEZ
Hi,
i would like to remove product name from breadcrumb on product pages.
5 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now