Jump to content

[Free module] Prestashop 1.6 modern breadcrumb (data-vocabulary.org schema fix)


Recommended Posts

Thanks.

2 problems :

  • in .php : ltrim to avoid the space in content=" aaaa"
    'title' => ltrim($lastItem), ltrim($link->nodeValue),
  • showing 5 items in source code (position 5) but I need only 4 items to display ... the 5th sets just the link (no content no name) and it is the same link as the 4th element.

Share this post


Link to post
Share on other sites

Hi Daresh, thank you for the module. I'm not a coder and I see all kinds of different 'breadcrumps'.

I installed your module, but in my breadcrumb file I do not know where exactly I need to override the code and insert your hook.

This is my breadcrumb code at the moment:

<!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
<div class="breadcrumb clearfix">
	<a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}"><i class="icon-home"></i></a>
	{if isset($path) AND $path}
		<span class="navigation-pipe"{if isset($category) && isset($category->id_category) && $category->id_category == (int)Configuration::get('PS_ROOT_CATEGORY')} style="display:none;"{/if}>{$navigationPipe|escape:'html':'UTF-8'}</span>
		{if $path|strpos:'span' !== false}
			<span class="navigation_page">{$path|@replace:'<a ': '
				<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
					<a itemprop="url" '|@replace:'data-gg="">': '>
						<span itemprop="title">'|@replace:'</a>': '</span>
					</a>
				</span>'}
			</span>
		{else}
			{$path}
		{/if}
	{/if}
</div>
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
	<strong>
		{capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture}
		<a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back">
			<i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
		</a>
	</strong>
</div>
{/if}
<!-- /Breadcrumb -->

Can you please tell me what code I need to replace with your hook? Thank you so much.

Ellen

Share this post


Link to post
Share on other sites

I used your module, but Google keeps pointing out there are 3 products not fulfilling breadcrumb requirements. As far as I understand, this mod addresses the issue on the entire theme and anyway the issue itself shouldn't be related to single items, am I wrong?

breadcrumb.jpg

Share this post


Link to post
Share on other sites

Ok, a very stupid "solution" to the issue that never pops up into my mind I'm posting just for other newbies like me: refresh the cache FROM BACKOFFICE after applying the changes to the code...any other newbie mean won't work :)

Now Google is validating the changes, assessing whether they're effective or not. It says it will take some days for it.

I'll keep you updated.

@Daresh thank you for your prompt support! Very appreciated!

 

Edited by JRCFirewalker (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

Hi Daresh,

I probed you module and it looks to work fine now.(I did it before but replacing complete code on the template...

Just two questions, when reviewing goggle results after module and refreshing cache, I see that there are some field (optional) but missing like :

Brand, review SBN, url and availability. How can I do to show these info?

example: https://www.delica-te-zen.com/comprar-te-rojo/146-te-pu-erh-mango-maracuya.html

Second question, is more about cosmetic issue, but since place the hook the icon for root (Home) disappears from breadcrumb in the top, do you expect implement to show the home location?

Thanks

Share this post


Link to post
Share on other sites

I'm with your module, but I still have errors .

Tnx.

 <!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
  {hook h='displayModernBreadCrumb' path=$path}
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
    <strong>
        {capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture}
        <a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back">
            <i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
        </a>
    </strong>
</div>
{/if}
<!-- /Breadcrumb -->

Screenshot_2020-01-22 Инструмент за тестване на структурирани данни.png

Share this post


Link to post
Share on other sites

Great module, thank for sharing. Works btw as well for 1.5.6, so there is thus no need to limit the usage to minimum 1.6.

But there is a difference: Neither in 1.6 nor in 1.5 the last path item shows up like before with your module installed. Where is the adjusting screw to fix this little mistake? ;)

 

Edited by Wuschel (see edit history)

Share this post


Link to post
Share on other sites

It's not a mistake, cause AFAIK the last part of the breadcrumb is also required to be linked. Prestashop 1.7 has it done exaclty like this.

Thanks for the info about the version, I'll check it out.

Share this post


Link to post
Share on other sites

Who cares for 1.5? ;)

But it's simple, if you don't want the last item to be linked, you can change the foreach loop in the module's tpl file to this:

{foreach from=$breadcrumbLinks item=breadcrumbLink}
        <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            {if !$breadcrumbLink.last}
                <a itemprop="item" href="{$breadcrumbLink.href}" title="{$breadcrumbLink.title}">
                    {$breadcrumbLink.title}
                </a>
                <span class="navigation-pipe">{$navigationPipe}</span>
            {else}
                {$breadcrumbLink.title}
            {/if}
            <meta itemprop="position" content="{$breadcrumbLink.position}">
            <meta itemprop="name" content="{$breadcrumbLink.title}">
        </span>
    {/foreach}

Seems it's still correctly validated by the snippets testing tool.

Share this post


Link to post
Share on other sites

I would need to see the specific case, cause the module should link every list item.

And I just uploaded a new version, where you can decide if you want the last item to be linked when executing the hook.

Share this post


Link to post
Share on other sites
13 hours ago, Daresh said:

If you don't want the last item to be linked, you execute the hook like this: {hook h='displayModernBreadCrumb' path=$path} (according to Google's specs the last item is not required to be a link)

Thank you again, I really appreciate this. I'll check it out tomorrow. It's just that in my opinion the navigation of a shop system should first and foremost serve the customer - and not Google.

Edited by Wuschel (see edit history)

Share this post


Link to post
Share on other sites

Hi,

thx for your module.

I have a question: i have the prestashop's version 1.6.1.4 and i have installed 1.1.0 . Is it correct? Or i must install the version 1..0.2??

Thx for response.

 

Bye

Share this post


Link to post
Share on other sites
19 hours ago, Daresh said:

This part needs to be removed and replaced with the code from my module:

284826392_2020-01-2214_25_17-FreemodulePrestashop1.6modernbreadcrumb(data-vocabulary.orgschemafix).png.cce52fb40b23ddb5c454a1326cd2d739.png

Thank you Daresh, I implemented it and Google is now validating. Hopefully it's resolved. Thanks again for the module and the help.

Ellen

  • Like 1

Share this post


Link to post
Share on other sites

@Daresh Thanks a lot for your work and the module. It's maybe a stupid question, but if an older version of your module is already installed and I want to update, can the new version simply be uploaded or should the old one be removed first?

Share this post


Link to post
Share on other sites

I don't understand, where to insert that hook...

If you want the last item to be linked, you execute the hook like this: {hook h='displayModernBreadCrumb' path=$path linkLast=true}

If you don't want the last item to be linked, you execute the hook like this: {hook h='displayModernBreadCrumb' path=$path} (according to Google's specs the last item is not required to be a link)

Edited by Claudiocool (see edit history)

Share this post


Link to post
Share on other sites
1 hour ago, Claudiocool said:

I don't understand, where to insert that hook...

If you want the last item to be linked, you execute the hook like this: {hook h='displayModernBreadCrumb' path=$path linkLast=true}

If you don't want the last item to be linked, you execute the hook like this: {hook h='displayModernBreadCrumb' path=$path} (according to Google's specs the last item is not required to be a link)

Add the hook in the breadcrumb.tpl file of your theme (/themes/your_theme/breadcrumb.tpl)

Like this: 

breadcrumbs_hook.png

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, NSN said:

@Daresh Thanks a lot for your work and the module. It's maybe a stupid question, but if an older version of your module is already installed and I want to update, can the new version simply be uploaded or should the old one be removed first?

Just upload the new module.

  • Thanks 1

Share this post


Link to post
Share on other sites

Daresh, I'm not sure how to 'read' the Google warning. Yesterday there were 78 warnings. I installed your module and edited the breadcrumb.tpl but today I have 181 warnings.

Did it not work? Hopefully you can shed some light on it. Do you need some specific information? 

 

Share this post


Link to post
Share on other sites

Thank you very much for this nice module !

However I see always errors on my host server :

Quote

[Fri Jan 24 15:51:43.336228 2020] [:error] [pid 166526:tid 140510819755776] [client 66.249.64.228:55532] FastCGI:
server "/home/clients/xxxxxxxxxxxxxxxxxx/.config/apache/xxxxxxxxxxxxxx.xx.ch/.fpm/php5.external"
stderr: PHP message: PHP Warning:  DOMDocument::loadHTML():
Empty string supplied as input in /home/clients/8xxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxx.xx.ch/httpdocs/modules/gmbreadcrumb/gmbreadcrumb.php on line 48

[Fri Jan 24 15:47:44.904573 2020] [:error] [pid 158947:tid 140510735828736] [client 66.249.64.228:36586] FastCGI:
server "/home/clients/xxxxxxxxxxxxxxxxxx/.config/apache/xxxxxxxxxxxxxx.xx.ch/.fpm/php5.external"
stderr: PHP message: PHP Warning:  DOMDocument::loadHTML():
Empty string supplied as input in /home/clients/xxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxx.xx.ch/httpdocs/modules/gmbreadcrumb/gmbreadcrumb.php on line 48

Seems this line gives errors  (line : 48):

 $dom->loadHTML(mb_convert_encoding($path, 'HTML-ENTITIES', 'UTF-8'));

Thank you

 

Edited by myselfidem (see edit history)

Share this post


Link to post
Share on other sites

It's just a warning, so it will not break your site. It would be good to know if it happens for a page that should have a breadcrumb, or maybe for some reason the path is indeed empty?

Do you know for what page request you have this warning?

Share this post


Link to post
Share on other sites

The module works wonderfully but I am having an issue with either CMS that are in categories: the last item does not show and Google says the name is missing (which it is since the title of the last page is not there) and with the BLOG module, you get another arrow with nothing and Google again calls for an empty name.

Example CMS: https://librairiezbookstore.com/en/info/informations/accepted-payment-methods

Example BLOG 1: https://librairiezbookstore.com/NEWS

Example BLOG 2: https://librairiezbookstore.com/en/NEWS/post/straight-to-hell.html

Other than that, everything works great. Thank you for the module!

Share this post


Link to post
Share on other sites

Breadcrumb is reduntant on cms pages. I've added "cms" pages to header.tpl not to be displayed - the same as index and pagenotfound pages:

                    {if $page_name !='index' && $page_name !='pagenotfound' && $page_name !='cms'}
                        {include file="$tpl_dir./breadcrumb.tpl"}
                    {/if}

Share this post


Link to post
Share on other sites
19 hours ago, Daresh said:

Thanks for your feedback guys, I just updated the module to v. 1.1.1 and uploaded it into the first post, check it out!

Hi Daresh,

 

how to update to the new version? Just un install the old one and load the new? or there is any other better way how to?

Thanks!

Share this post


Link to post
Share on other sites
42 minutes ago, Daresh said:

Just upload the new module. You may also verify the way you execute the hook, if you want the last item to be a link.

OK, thanks. Is it recomendable for SEO pourposes to include the last link?

 

Share this post


Link to post
Share on other sites

Thanks for this! Just a question, our theme have some user defined variables inside breadcrumb.tpl (we use Warehouse):

 

<div class="breadcrumb clearfix {if isset($warehouse_vars.breadcrumb_width) && $warehouse_vars.breadcrumb_width == 0}fullwidth-breadcrumb{/if}">
	{if isset($warehouse_vars.breadcrumb_width) && $warehouse_vars.breadcrumb_width == 0}<div class="container">{/if}
		<a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}"><i class="icon-home"></i></a>
	{if isset($path) AND $path}
		<span class="navigation-pipe"{if isset($category) && isset($category->id_category) && $category->id_category == (int)Configuration::get('PS_ROOT_CATEGORY')} style="display:none;"{/if}>{$navigationPipe|escape:'html':'UTF-8'}</span>
		{if $path|strpos:'span' !== false}
			<span class="navigation_page">{$path|@replace:'<a ': '<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a itemprop="url" '|@replace:'data-gg="">': '><span itemprop="title">'|@replace:'</a>': '</span></a></span>'}</span>
		{else}
			{$path}
		{/if}
	{/if}

		{if $page_name == 'product'}
		{hook h='productnavs'}
		{/if}

{if isset($warehouse_vars.breadcrumb_width) && $warehouse_vars.breadcrumb_width == 0}</div>{/if}
</div>

 

If I replace this with your module hook, would it affect how things related to breadcrumb looks? Or should I also edit your gmbreadcrumb.tpl so it's compatible with the theme?

Share this post


Link to post
Share on other sites

It may affect how the breadcrumb looks, but your code seems to be using a lot of custom variables, so I don't think my module will work for you if you wan to keep all this markup.

Share this post


Link to post
Share on other sites
19 minutes ago, Daresh said:

It may affect how the breadcrumb looks, but your code seems to be using a lot of custom variables, so I don't think my module will work for you if you wan to keep all this markup.

Ah that's too bad, what exactly would I have to change in it to be able to use the new Schema?

Share this post


Link to post
Share on other sites

The question is are you using the full with breadcrumb? If not then I think you can try to use my module, but probably you would need to insert that hook execution into the module's tpl file.

Share this post


Link to post
Share on other sites
7 minutes ago, Daresh said:

The question is are you using the full with breadcrumb? If not then I think you can try to use my module, but probably you would need to insert that hook execution into the module's tpl file.

Do you mean full width? If so, no.

Share this post


Link to post
Share on other sites
On 1/24/2020 at 9:17 AM, Daresh said:

Use the snippets testing tool to verify your breadcrumb: https://search.google.com/structured-data/testing-tool/u/0/?hl=en

Hi Daresh, I ran the test: https://search.google.com/structured-data/testing-tool/u/0/?hl=en#url=https%3A%2F%2Fwww.bike4travel.nl
I see some errors, but I don't know if they are related to your module (I'm not a programmer, we try to do this ourselves and sometimes things get complicated :) )

Thanks again.

Share this post


Link to post
Share on other sites

Those errors are not related to breadcrumbs, those are errors with products. I see errors like this often on prestashop 1.6, the default theme had those errors and other themes got them after it.

Share this post


Link to post
Share on other sites

I add the gmbreadcrumb_1_1_1 module to my Prestashop 1.6.1.3 and it tells me that it has been downloaded correctly, but then it does not appear in the list of modules to configure it.

Which may be due?

Thank you so much.
regards

Share this post


Link to post
Share on other sites

Another important update - I made this module with an assumption that the current page should be a link, but it's actually not required by Google.

So the best solution would be to only modify the breadcrumb.tpl, replacing it's contents with this code:

<!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
{if !empty($path)}
{$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}
{$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}
<div class="clearfix">
	<ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> 
			<a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}" itemprop="item">
				<i class="icon-home"></i>
			</a>
			<meta itemprop="name" content="{l s='Home'}" />
			<meta itemprop="position" content="1" />
		</li>
{if !empty($breadcrumbs)}
{foreach from=$breadcrumbs item=breadcrumb name=crumbs}
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
{if !empty($breadcrumb.url)}
			<a href="{$breadcrumb.url}" itemprop="item" title="{$breadcrumb.title}">
				<span itemprop="name">{$breadcrumb.title}</span>
			</a>
{else}
			<span itemprop="name">{$breadcrumb.title}</span>
{/if}
			<meta itemprop="position" content="{($smarty.foreach.crumbs.iteration|intval + 1)}" />
		</li>
{/foreach}
{/if}
	</ol>
</div>
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
	<strong>
		{capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture}
		<a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back">
			<i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
		</a>
	</strong>
</div>
{/if}
<!-- /Breadcrumb -->

That's the most simple solution, and finally we have a correct code of the breadcrumb.tpl file.

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, Daresh said:

Another important update - I made this module with an assumption that the current page should be a link, but it's actually not required by Google.

So the best solution would be to only modify the breadcrumb.tpl, replacing it's contents with this code:


<!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
{if !empty($path)}
{$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}
{$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}
<div class="clearfix">
	<ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> 
			<a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}" itemprop="item">
				<i class="icon-home"></i>
			</a>
			<meta itemprop="name" content="{l s='Home'}" />
			<meta itemprop="position" content="1" />
		</li>
{if !empty($breadcrumbs)}
{foreach from=$breadcrumbs item=breadcrumb name=crumbs}
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
{if !empty($breadcrumb.url)}
			<a href="{$breadcrumb.url}" itemprop="item" title="{$breadcrumb.title}">
				<span itemprop="name">{$breadcrumb.title}</span>
			</a>
{else}
			<span itemprop="name">{$breadcrumb.title}</span>
{/if}
			<meta itemprop="position" content="{($smarty.foreach.crumbs.iteration|intval + 1)}" />
		</li>
{/foreach}
{/if}
	</ol>
</div>
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
	<strong>
		{capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture}
		<a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back">
			<i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
		</a>
	</strong>
</div>
{/if}
<!-- /Breadcrumb -->

That's the most simple solution, and finally we have a correct code of the breadcrumb.tpl file.

Hi Daresh,

 

now I´m really cofused. So, we can un install the module and simply replace the original breadcrumb.tpl in our theme with this new code?

Thanks for clarification and your time.

Share this post


Link to post
Share on other sites

I have created/updated origional breadcump.tpl and added pages who i wanted to include.

Page to include?/exclude  you do update in the lines highligted

working perfect in prestashop 1.6 versions.

ps dont forget to backup your origional before copy past 

<!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
<div class="breadcrumb" {if $page_name == 'product' or $page_name == 'category' or $page_name == 'cms' or $page_name == 'new-products' or $page_name == 'best-sales' or $page_name == 'prices-drop' or $page_name == 'manufacturer' or $page_name == 'sitemap' or $page_name == 'content' or $page_name == 'stores' or $page_name == 'search'}itemscope itemtype="http://schema.org/BreadcrumbList"{/if}>
<!--    <div class="container"  > -->
        <!--<meta itemprop="name" content="{$meta_title|escape:'html':'UTF-8'}"/>-->
        <span {if $page_name == 'product' or $page_name == 'category' or $page_name == 'cms' or $page_name == 'new-products' or $page_name == 'best-sales' or $page_name == 'prices-drop' or $page_name == 'manufacturer' or $page_name == 'sitemap' or $page_name == 'content' or $page_name == 'stores' or $page_name == 'search'}itemprop="itemListElement" itemscope="" itemtype="http://schema.org/ListItem"{/if}><meta itemprop="position" content="1"><a class="home" itemprop="item" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}"><meta itemprop="name" content="{l s='Home'}" /><i class="icon-home"></i></a></span>
    {if isset($path) AND $path}
        <span  class="navigation-pipe"  {if isset($category) && isset($category->id_category) && $category->id_category == (int)Configuration::get('PS_ROOT_CATEGORY')} style="display:none;"{/if}>{$navigationPipe|escape:'html':'UTF-8'}</span>
        {if $page_name == 'product' or $page_name == 'category' or $page_name == 'cms' or $page_name == 'new-products' or $page_name == 'best-sales' or $page_name == 'prices-drop' or $page_name == 'manufacturer' or $page_name == 'sitemap' or $page_name == 'content' or $page_name == 'stores' or $page_name == 'search'}
            {if $path|strpos:'span' !== false}
                <span  class="navigation_page" >
                {$path|@replace:'<a ': '<span > <span >
                    <a itemprop="item" '|@replace:'data-gg="">': '>
                    <span >'|@replace:'</a>': '</a></span></span>'}</span>
            {else}
                <span itemprop="itemListElement" class="item-breadcrumb" itemscope="" itemtype="http://schema.org/ListItem"><meta itemprop="position" content="1"><meta itemprop="item" content="{if isset($force_ssl) && $force_ssl}https://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}{else}http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}{/if}" /><meta itemprop="name" content="{$path}" /><span class="item-breadalone">{$path}</span></span>
            {/if}
        {else}
            {if $path|strpos:'span' !== false}
                <span  class="navigation_page" >
                {$path|@replace:'<a ': '<span > <span >
                    <a '|@replace:'data-gg="">': '>
                    <span >'|@replace:'</a>': '</a></span></span>'}</span>
            {else}
                <span class="item-breadalone">{$path}</span>
            {/if}
        {/if}
    {/if}
</div>

  • Thanks 2

Share this post


Link to post
Share on other sites
On 1/28/2020 at 8:22 AM, Daresh said:

Another important update - I made this module with an assumption that the current page should be a link, but it's actually not required by Google.

So the best solution would be to only modify the breadcrumb.tpl, replacing it's contents with this code:


<!-- Breadcrumb -->
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
{if !empty($path)}
{$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}
{$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}
<div class="clearfix">
	<ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> 
			<a class="home" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Return to Home'}" itemprop="item">
				<i class="icon-home"></i>
			</a>
			<meta itemprop="name" content="{l s='Home'}" />
			<meta itemprop="position" content="1" />
		</li>
{if !empty($breadcrumbs)}
{foreach from=$breadcrumbs item=breadcrumb name=crumbs}
		<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
{if !empty($breadcrumb.url)}
			<a href="{$breadcrumb.url}" itemprop="item" title="{$breadcrumb.title}">
				<span itemprop="name">{$breadcrumb.title}</span>
			</a>
{else}
			<span itemprop="name">{$breadcrumb.title}</span>
{/if}
			<meta itemprop="position" content="{($smarty.foreach.crumbs.iteration|intval + 1)}" />
		</li>
{/foreach}
{/if}
	</ol>
</div>
{if isset($smarty.get.search_query) && isset($smarty.get.results) && $smarty.get.results > 1 && isset($smarty.server.HTTP_REFERER)}
<div class="pull-right">
	<strong>
		{capture}{if isset($smarty.get.HTTP_REFERER) && $smarty.get.HTTP_REFERER}{$smarty.get.HTTP_REFERER}{elseif isset($smarty.server.HTTP_REFERER) && $smarty.server.HTTP_REFERER}{$smarty.server.HTTP_REFERER}{/if}{/capture}
		<a href="{$smarty.capture.default|escape:'html':'UTF-8'|secureReferrer|regex_replace:'/[\?|&]content_only=1/':''}" name="back">
			<i class="icon-chevron-left left"></i> {l s='Back to Search results for "%s" (%d other results)' sprintf=[$smarty.get.search_query,$smarty.get.results]}
		</a>
	</strong>
</div>
{/if}
<!-- /Breadcrumb -->

That's the most simple solution, and finally we have a correct code of the breadcrumb.tpl file.

Hello, this fix works also for prestashop 1.7 ?

Share this post


Link to post
Share on other sites
  • 3 weeks later...
On 28/1/2020 at 8:22, Daresh said:

Otra actualización importante: hice este módulo con la suposición de que la página actual debería ser un enlace, pero en realidad Google no lo requiere.

Entonces, la mejor solución sería modificar solo breadcrumb.tpl, reemplazando su contenido con este código:



 
	   
		    
			    
				 
			
			   
			   
		
		   
			   
				 
			
			 
			   
		
	

 
	
		  
			 
	

Esa es la solución más simple, y finalmente tenemos un código correcto del archivo breadcrumb.tpl.

el menu horizontal en el telefono movil no funciona a que puede deverse 

Share this post


Link to post
Share on other sites

Hello everyone.

I followed the instructions as described above. Google sees everything correctly and all warnings have disappeared. Unfortunately, the bread crumbs on the page look like above. One line has made a lot and I can't handle it. Could someone possibly help me.

Of course, I cleared the cache and smarty and compiled the template

Thank you.

Filip

 

Zrzut ekranu 2020-03-8 o 17.53.42.png

Share this post


Link to post
Share on other sites
  • 3 weeks later...

Hi thank you for your module ! Where can I change the code please? I am on Presta 1.6.1.12 and I have this Breadcrumb file :

<! - Breadcrumb ->
{if isset ($ smarty.capture.path)} {assign var = 'path' value = $ smarty.capture.path} {/ if}
<section class = "breadcrumb" xmlns: v = "http://rdf.data-vocabulary.org/#">
    <ul itemprop = "breadcrumb">
    <li typeof = "v: Breadcrumb"> <a class = "home" href = "{if isset ($ force_ssl) && $ force_ssl} {$ base_dir_ssl} {else} {$ base_dir} {/ if} "title =" {ls = 'Return to Home'} "rel =" v: url "property =" v: title "> {ls = 'Home'} </a> </li> {if isset ($ path) AND $ path} <li class = "navigation-pipe" {if isset ($ category) && isset ($ category-> id_category ) && $ category-> id_category == (int) Configuration :: get ('PS_ROOT_CATEGORY')} style = "display: none;" {/ if}> {$ navigationPipe} </li>
        {if! $ path | strpos: 'li>'! == false}
            <li typeof = "v: Breadcrumb" classe = "navigation_page"> {$ path} </li>
        {else}
            {$ path}
        {/ if}
    {/ if}
    </ul>
</section>
{if isset ($ smarty.get.search_query) && isset ($ smarty.get.results) && $ smarty.get. résultats> 1 && isset ($ smarty.server.HTTP_REFERER)}
<div id = "search_return" class = "pull-right hidden-xs">
    {capture} {if isset ($ smarty.get.HTTP_REFERER) && $ smarty. get.HTTP_REFERER} {$ smarty.get.HTTP_REFERER} {elseif isset ($ smarty.server.HTTP_REFERER) && $ smarty.server.HTTP_REFERER} {$ smarty.server.HTTP_REFERER} {/ if} {/ capture}
    <a href = "{$ smarty.capture.default | escape: 'html': 'UTF-8' | secureReferrer | regex_replace: '/ [\? | &] content_only = 1 /': ''}" name = "back"rel = "nofollow">
        <i class = "icon-left-open-3"> </i> {ls = 'Retour aux résultats de recherche pour "% s" (% d autres résultats)' sprintf = [$ smarty.get.search_query, $ smarty .get.results]}
    </a>
</div>
{/ if}
<! - / Breadcrumb ->

Share this post


Link to post
Share on other sites