Jump to content

Нужна помощь с хлебными крошками


Go to solution Solved by ps-simpla,

Recommended Posts

В каталоге, в хлебных крошках выводятся ссылки на категории, как сделать, чтобы последняя ссылка категории не была кликабельна, а то ведет сама на себя. Очень нужна помощь. Спасибо)

 

<!-- Хлебные крошки /-->
<div xmlns:v="http://rdf.data-vocabulary.org/#" class="breadcrumbs">
 <span typeof="v:Breadcrumb"><a href="/" rel="v:url" property="v:title">Главная</a></span>
	{if $category}
{foreach $category->path as $cat}  
	/<span typeof="v:Breadcrumb">
    <a href="catalog/{$cat->url}" rel="v:url" property="v:title">{$cat->name|escape}</a>
    </span>
  {/foreach} 
	{if $keyword}
	/ Поиск
	{/if}
    {/if}
</div>
<!-- Хлебные крошки #End /-->

 

post-20417-0-86924400-1465923493_thumb.png

Link to post
Share on other sites

 

{foreach $category->path as $cat}  
	{if $cat@last}
		/<span typeof="v:Breadcrumb">
			{$cat->name|escape}
		</span>
	{else}
		/<span typeof="v:Breadcrumb">
			<a href="catalog/{$cat->url}" rel="v:url" property="v:title">{$cat->name|escape}</a>
		</span>
	{/if}
{/foreach} 

Спасибо большое, выручили!

Link to post
Share on other sites

Доброго времени! Вот еще вариант - аля - костыль)))) через псевдо-элемент

 

*:last-child {
   pointer-events: none;
}

Соответсвенно вместо звездочки вписываете свои селекторы.

 

P.S Элемент останется ссылкой НО перейти по ней будет невозможно и поведение будет как у НЕссылки.

Edited by LSDance
Link to post
Share on other sites

1. Предложенный метод формально поставленную задачу решает, но портит хлебные крошки для страниц типа категория-бренд...

2. Прежде чем изобретать давно изобретенное, полезно было бы посмотреть поиск на "хлебные крошки"...

Link to post
Share on other sites
  • 1 year later...

Все, получилось иначе, заменил в крошках products.tpl ссылку на <span>
Правда если зайти не на прямую в бренды, а в бренды каталога, то пропадает ссылка на бренд (в котором находимся) вместе с самой категорией. Как я понял из перечитки форума - так заточен движек и иначе не выйдет, верно?

Link to post
Share on other sites

Правда если зайти не на прямую в бренды, а в бренды каталога, то пропадает ссылка на бренд (в котором находимся) вместе с самой категорией. Как я понял из перечитки форума - так заточен движек и иначе не выйдет, верно?

Нет, не верно.
Link to post
Share on other sites
  • 9 months later...

Подскажите, есть такой урл ведь еще

/catalog/Категория/Бренд

Так вот там получается и ссылка на категорию не активна и на бренд тоже.

 

Код

<div id="path" class="breadcrumbs">
   <a href="/">Главная</a>
   {if $category}
   {foreach from=$category->path item=cat}
	   {if $cat@last}
			<sup>/</sup><span>{$cat->name|escape}</span>
	   {else}
			<sup>/</sup><a href="catalog/{$cat->url}">{$cat->name|escape}</a>
	   {/if}   
   {/foreach}
   {if $brand}
   <sup>/</sup><span>{$brand->name|escape}</span>
   {/if}
   {elseif $brand}
   <sup>/</sup><span>{$brand->name|escape}</span>
   {elseif $keyword}
   <sup>/</sup><span>Поиск</span>
   {/if}
</div>
Link to post
Share on other sites

Так все работает идеально

<div id="path" class="breadcrumbs">
   <a href="/">Главная</a> 
	{if $category}
		{foreach $category->path as $cat}
			{if !$cat@last || $brand}<sup>/</sup><a href="catalog/{$cat->url}">{$cat->name|escape}</a>{/if}
		{/foreach}  
	{/if} 
	<span>
	{if $keyword}По запросу "{$keyword|escape}" найдено:
	{elseif $page}<sup>/</sup>{$page->name|escape}
	{else}<sup>/</sup>{$category->name|escape} {$brand->name|escape} {$keyword|escape}
	{/if}</span>
</div>

Link to post
Share on other sites
  • 2 years later...

Подскажите пожалуйста, как выводить нумерацию по возрастанию в

<meta itemprop="position" content="1" />

Где в категории content="1" цифра меняется в следующем на 2, 3, 4....?

Вот немного моего кода:

		<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
			<a itemprop="item" href="/">
				<span itemprop="name">Главная</span>
			</a>
			<meta itemprop="position" content="1" />
		</li>

		{if $category}
			{foreach $category->path as $cat}
				<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
					{if $cat->id != $category->id || $brand}
						<a itemprop="item" href="./{$cat->url}">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</a>
					{else}
						<span itemprop="name">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</span>
					{/if}
					<meta itemprop="position" content="{$cat->id}" />
				</li>
			{/foreach}
		{/if}
		

 

Link to post
Share on other sites
1 час назад, get31 сказал:

Подскажите пожалуйста, как выводить нумерацию по возрастанию в


<meta itemprop="position" content="1" />

Где в категории content="1" цифра меняется в следующем на 2, 3, 4....?

Вот немного моего кода:


		<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
			<a itemprop="item" href="/">
				<span itemprop="name">Главная</span>
			</a>
			<meta itemprop="position" content="1" />
		</li>

		{if $category}
			{foreach $category->path as $cat}
				<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
					{if $cat->id != $category->id || $brand}
						<a itemprop="item" href="./{$cat->url}">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</a>
					{else}
						<span itemprop="name">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</span>
					{/if}
					<meta itemprop="position" content="{$cat->id}" />
				</li>
			{/foreach}
		{/if}
		

 

 

{$level = 1}
<ol>
		<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
			<a itemprop="item" href="/">
				<span itemprop="name">Главная</span>
			</a>
			<meta itemprop="position" content="{$level++}" />
		</li>

		{if $category}
			{foreach $category->path as $cat}
				<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
					{if $cat->id != $category->id || $brand}
						<a itemprop="item" href="./{$cat->url}">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</a>
					{else}
						<span itemprop="name">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</span>
					{/if}
					<meta itemprop="position" content="{$level++}" />
				</li>
			{/foreach}
		{/if}
</ol>

 

Link to post
Share on other sites
52 минуты назад, alexivchenko сказал:

 


{$level = 1}
<ol>
		<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
			<a itemprop="item" href="/">
				<span itemprop="name">Главная</span>
			</a>
			<meta itemprop="position" content="{$level++}" />
		</li>

		{if $category}
			{foreach $category->path as $cat}
				<li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
					{if $cat->id != $category->id || $brand}
						<a itemprop="item" href="./{$cat->url}">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</a>
					{else}
						<span itemprop="name">{if $cat->breadcrumb_name}{$cat->breadcrumb_name|escape}{else}{$cat->name|escape}{/if}</span>
					{/if}
					<meta itemprop="position" content="{$level++}" />
				</li>
			{/foreach}
		{/if}
</ol>

 

Спасибо!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...