Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Микроразметка ддя Хлебных крошек


Recommended Posts

  • 3 weeks later...

 

Помогите правильно разметить хлебные крошки, провозился день уже. Думаю ошибка в поле "position" так как все остальное выводится.

<script type="application/ld+json">
    {
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement":
     [
     {% for breadcrumb in breadcrumbs %}
      {
       "@type": "ListItem",
       "position": {% if key + 1 < breadcrumbs|length %},
       "item":
       {
        "@id": "{{ breadcrumb.href }}",
        "name": "{{ breadcrumb.text }}"
        }
      },
      {% endif %}
{% endfor %}
     ]
    }
    </script>

Link to comment
Share on other sites


Готовое решение РАЗМЕТКА ХЛЕБНЫХ КРОШЕК OPENCART 3

<script type="application/ld+json">
    {
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement":
     [
     {% for key,breadcrumb in breadcrumbs %}
      {
       "@type": "ListItem",
       "position": {{ key+1 }},
       "item":
       {
        "@id": "{{ breadcrumb.href }}",
        "name": "{{ breadcrumb['text']|striptags }}"
        }
      {% if loop.last == false %}
  },  
  {% else %}
  }
  {% endif %}
{% endfor %}
 ]
}
</script>

Link to comment
Share on other sites


  • 4 months later...
В 09.10.2020 в 20:13, Spermer сказал:

Готовое решение РАЗМЕТКА ХЛЕБНЫХ КРОШЕК OPENCART 3

<script type="application/ld+json">
    {
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement":
     [
     {% for key,breadcrumb in breadcrumbs %}
      {
       "@type": "ListItem",
       "position": {{ key+1 }},
       "item":
       {
        "@id": "{{ breadcrumb.href }}",
        "name": "{{ breadcrumb['text']|striptags }}"
        }
      {% if loop.last == false %}
  },  
  {% else %}
  }
  {% endif %}
{% endfor %}
 ]
}
</script>

Добрый вечер!

Подскажите, а в какую часть кода вставить? У меня сейчас вот так.

 

<ul class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
    {% for key, breadcrumb in breadcrumbs %}
       {% if key + 1 < breadcrumbs|length %}
      <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
         <a itemscope itemtype="https://schema.org/Thing" itemprop="item" href="{{ breadcrumb.href }}"><span itemprop="name">{{ breadcrumb.text }}</span></a>
         <meta itemprop="position" content="{{key+1}}" />
         </li>
          {% else %}
        <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">{{ breadcrumb.text }}</span>
              <meta itemprop="position" content="{{key+1}}" />
              </li>
    {% endif %}
    {% endfor %}
  </ul>

Link to comment
Share on other sites


  • 1 month later...
2 часа назад, ektomorf сказал:

 

Как вариант готовое решение 

 

Link to comment
Share on other sites

  • 2 months later...
В 22.01.2020 в 14:13, chukcha сказал:

поделюсь своей
 


<div class="breadcrumb prod"  itemscope itemtype="https://schema.org/BreadcrumbList">
        <?php $i=0; $count = count($breadcrumbs);
		foreach ($breadcrumbs as $breadcrumb) { ?>
		<?php if ($i==0) $class=' class="b_home"'; else $class=' class="b_item"';?>
		<span  itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" <?php echo $class;?>>
			<?php if ($i<$count-1) { ?>
				<a href="<?php echo $breadcrumb['href']; ?>" itemprop="item"><span itemprop="name"><?php echo $breadcrumb['text']; ?></span></a>
			<?php } else { ?>
			<span   itemprop="name"><?php echo $breadcrumb['text']; ?></span>
			<meta itemprop="item" content="<?php echo $breadcrumb['href']; ?>" />
			<?php } ?>
			<meta itemprop="position" content="<?php echo $i+1; ?>" />
		</span>
		<?php if ($i <$count-1) {?>
			<span class="b_sep"></span>
		<?php } ?>

        <?php $i++; } ?>
</div>



 

 Добрый день! как добавить "/" между страницами переходами в вашем коде?

Link to comment
Share on other sites


4 часа назад, ArtemiY777 сказал:

 Добрый день! как добавить "/" между страницами переходами в вашем коде?

 

4 часа назад, ArtemiY777 сказал:

 Добрый день! как добавить "/" между страницами переходами в вашем коде?

разобрался)

Link to comment
Share on other sites


  • 7 months later...

Настроил под себя

 


<script type="application/ld+json">
    {
     "@context": "http://schema.org",
     "@type": "BreadcrumbList",
     "itemListElement":
     [
     {% for key,breadcrumb in breadcrumbs %}
       {% if key != 0 %}
        {
         "@type": "ListItem",
         "position": {{ key }},
         "item":
         {
          "@id": "{{ breadcrumb.href }}",
          "name": "{{ breadcrumb['text']|striptags }}"
          }
          {% if loop.last == false %}
          },
          {% else %}
          }
          {% endif %}
        {% endif %}
      {% endfor %}
     ]
    }
</script>

 

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
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.