Отсутствует поле "item" — ошибка в Гугл вебмастере14.08.2021 От: faq Из: Веб-строительство AlexMistix 8 мая 2020, 20:36 304Всем привет, может поможет кто разобраться. Ругается на цепочку крошек, может я упустил что-то из виду.Ругается вот на этот кусок кода:<li itemprop=»itemListElement» itemscope itemtype=»http://schema.org/ListItem» class=»trail-item trail-begin»><a href=»https://site.ru» rel=»home»><span itemprop=»name»>Главная</span></a><meta itemprop=»position» content=»1″ /></li>Код в шаблоне такой:// Open the unordered list.$breadcrumb .= ‘<ul class=»trail-items» itemscope itemtype=»http://schema.org/BreadcrumbList»>’;// Add the number of items and item list order schema.$breadcrumb .= sprintf( ‘<meta name=»numberOfItems» content=»%d» />’, absint( $item_count ) );$breadcrumb .= ‘<meta name=»itemListOrder» content=»Ascending» />’;// Loop through the items and add them to the list.foreach ( $this->items as $item ) { // Iterate the item position. ++$item_position; // Check if the item is linked. preg_match( ‘/(<a.*?>)(.*?)(</a>)/i’, $item, $matches ); // Wrap the item text with appropriate itemprop. $item = !empty( $matches ) ? sprintf( ‘%s<span itemprop=»name»>%s</span>%s’, $matches[1], $matches[2], $matches[3] ) : sprintf( ‘<span itemprop=»name»>%s</span>’, $item ); // Add list item classes. $item_class=»trail-item»; if ( 1 === $item_position && 1 < $item_count ) $item_class .= ‘ trail-begin’; elseif ( $item_count === $item_position ) $item_class .= ‘ trail-end’; // Create list item attributes. $attributes=»itemprop=»itemListElement» itemscope itemtype=»http://schema.org/ListItem» class=»» . $item_class . ‘»‘; // Build the meta position HTML. $meta = sprintf( ‘<meta itemprop=»position» content=»%s» />’, absint( $item_position ) ); // Build the list item. $breadcrumb .= sprintf( ‘<li %s>%s%s</li>’, $attributes, $item, $meta ); }// Close the unordered list.$breadcrumb .= ‘</ul>’;Помогите разобраться где что поправить? Sitealert 9 мая 2020, 09:17Как-то так надо:<a itemprop="item" href="https://site.ru" rel="home"><span itemprop="name">Главная</span></a> Похожие записи:Хлебные крошки в Opencart 2 Как проверить значение option у формы Как в хлебных крошках выводить только ID новости DLE 13.2 Ajax, json, jquery — не добавляется товар в корзине! Алгоритм построения самой длинной цепочки последовательности из заданных элементов
AlexMistix
Всем привет, может поможет кто разобраться. Ругается на цепочку крошек, может я упустил что-то из виду.
Ругается вот на этот кусок кода:
<li itemprop=»itemListElement» itemscope itemtype=»http://schema.org/ListItem» class=»trail-item trail-begin»><a href=»https://site.ru» rel=»home»><span itemprop=»name»>Главная</span></a><meta itemprop=»position» content=»1″ /></li>
Код в шаблоне такой:
// Open the unordered list.
$breadcrumb .= ‘<ul class=»trail-items» itemscope itemtype=»http://schema.org/BreadcrumbList»>’;
// Add the number of items and item list order schema.
$breadcrumb .= sprintf( ‘<meta name=»numberOfItems» content=»%d» />’, absint( $item_count ) );
$breadcrumb .= ‘<meta name=»itemListOrder» content=»Ascending» />’;
// Loop through the items and add them to the list.
foreach ( $this->items as $item ) {
// Iterate the item position.
++$item_position;
// Check if the item is linked.
preg_match( ‘/(<a.*?>)(.*?)(</a>)/i’, $item, $matches );
// Wrap the item text with appropriate itemprop.
$item = !empty( $matches ) ? sprintf( ‘%s<span itemprop=»name»>%s</span>%s’, $matches[1], $matches[2], $matches[3] ) : sprintf( ‘<span itemprop=»name»>%s</span>’, $item );
// Add list item classes.
$item_class=»trail-item»;
if ( 1 === $item_position && 1 < $item_count )
$item_class .= ‘ trail-begin’;
elseif ( $item_count === $item_position )
$item_class .= ‘ trail-end’;
// Create list item attributes.
$attributes=»itemprop=»itemListElement» itemscope itemtype=»http://schema.org/ListItem» class=»» . $item_class . ‘»‘;
// Build the meta position HTML.
$meta = sprintf( ‘<meta itemprop=»position» content=»%s» />’, absint( $item_position ) );
// Build the list item.
$breadcrumb .= sprintf( ‘<li %s>%s%s</li>’, $attributes, $item, $meta );
}
// Close the unordered list.
$breadcrumb .= ‘</ul>’;
Помогите разобраться где что поправить?
Sitealert
Как-то так надо: