Ссылки «назад-вперед» для блога и магазина.
Уважаемые знатоки. Подскажите,
1. как организовать в блоге 2 ссылки на предыдущие посты и 2 ссылки на следующие посты.
2. организовать в магазине (в карточке товара) 2 ссылки (ссылка-название + ссылка-фото) на предыдущие товары и 2 ссылки на следующие товары.
3 ответа
Возможно, эта информация будет полезна для реализации именно того, что вам нужно.
Читал, но, к сожалению, сам реализовать не могу. Забыл ссылку в данной теме добавить.
Где-то на старом форуме проскакивало... Это в магазине, но без фото.
<pre>
<!-- Кнопки Вперед/Назад -->
{$prev = null}
{$next = null}
{$siblings = $wa->shop->products("category/`$product.category_id`")}
{foreach $siblings as $sibling}
{if $sibling.id == $product.id}
{$next = $sibling}
{/if}
{if !$next && $sibling.id != $product.id}
{$prev = $sibling}
{/if}
{if $next && $sibling.id != $product.id}
{$next = $sibling}
{break}
{/if}
{/foreach}
{$last_sibling = end($siblings)}
{if $last_sibling.id == $product.id}
{$next = null}
{/if}
{if $prev || $next}
{* шаблон *}
<hr>
<table class="prev-next small">
<tr>
{if $prev && !$next}
<td class="arrow">←</td><td><a href="{$prev.frontend_url}">{$prev.name|escape}</a></td>
{elseif $next && !$prev}
<td></td><td class="half"></td>
<td class="half next"><a href="{$next.frontend_url}">{$next.name|escape}</a></td><td class="arrow">→</td>
{else}
<td class="arrow">←</td><td class="half"><a href="{$prev.frontend_url}">{$prev.name|escape}</a></td>
<td class="half next"><a href="{$next.frontend_url}">{$next.name|escape}</a></td><td class="arrow">→</td>
{/if}
</tr>
</table>
{/if}
<style>
table.prev-next { width: 100%; border: none; }
table.prev-next td { vertical-align: top; border: none; }
table.prev-next td.half { width: 49%; }
table.prev-next td.next { text-align: right; }
table.prev-next td.arrow { width: 1em; }
</style>
<!-- Конец Кнопки Вперед/Назад -->
</pre>