Jump to content

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


Daresh

Recommended Posts

Hello, I replaced the breacrumb.tpl but not sure how immediate it will effect the results. I cleared cache and tried but Google Search still giving me 19 pages with following errors

<span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a itemprop="url" href="https://barcodestripe.com/en/25-id-card-printers" title="ID Card Printers" ><span itemprop="title">ID Card Printers</span></a></span>

Link to comment
Share on other sites

  • 7 months later...

@Daresh, when using the last .tpl file I receive the following warning:

image.png.02cf9e1afca689262e868fb5d97046b1.png

The line in question is:


if (!empty($_smarty_tpl->tpl_vars['path']->value)) {
$_smarty_tpl->_assignInScope('matchCount', preg_match_all('/<a.+?href="(.+?)"[^>]*>([^<]*)<\/a>/',$_smarty_tpl->tpl_vars['path']->value,$_smarty_tpl->tpl_vars['matches']->value));
$_smarty_tpl->_assignInScope('breadcrumbs', array());
$_smarty_tpl->tpl_vars['i'] = new Smarty_Variable(null, $_smarty_tpl->isRenderingCache);
$_smarty_tpl->tpl_vars['i']->value = 0;

(second one)

What should I change?

Otherwise the file is workign excelent! 

Link to comment
Share on other sites

  • 7 months later...

Hello Daresh, I installed your code in prestashop 1.6 (themes/ breadcrumbs.tpl) 

however when google try to validate the fix, found some errors like still appears the data-vocabulary and the name of the product doesn't show up in the code.

Please look at the snipped shot. Thank you in advannce for your help.

data-vocabulary-deprecated-error.JPG

Link to comment
Share on other sites

Thank you for your reply. this is the code that I installed

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

Link to comment
Share on other sites

2 minutes ago, Daresh said:

It's not about the code, but where did you put it and do you see the change in your store code before sumbitting it to Google.

I installed in the folder themes/breadcrumbs.tpl ----------------It is wrong place?

 

Link to comment
Share on other sites

yes, I installed there and before that I check your code with schema.org because I was redirected from your posted link on google to there and your code is fine. 

I replaced the Themes/default-bootstrap/breadcrumb.tpl with your code , then I saved the changes and clear the cache in the back office. and then submitted the fix to google and this morning I got the message with the error.

schema-test.JPG

Link to comment
Share on other sites

  • 1 month later...

 

Hi, thank you for your solution. Now Google Search Console accepted the verification process. Just would like to check how to remove the third slash "/" ?

 

Here is the code:

 

{*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2014 PrestaShop SA
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}

<!-- Breadcrumb -->
<div class="breadcrumb_container">
<div class="container">
{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}
</div>
</div>
<!-- /Breadcrumb -->
 

ScreenShot2024-01-14at23_05_03.thumb.png.0a5b6138a414042272aef0e4d9c4007b.png

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