Jump to content

Кнопка "Показать все", фильтр по брендам.


Recommended Posts

Всем привет!!! Подскажите есть ли готовое решение? Показываем 10 брендов, затем кнопку "Показать все", затем раскрываем остальные.

Сделайте блок определенной высоты (учитывая 10 брендов), после нажатия через JS делайте его на 100%.
Link to post
Share on other sites
{* Фильтр по брендам *}
{if $category->brands}
<div id="brands">
	<a href="catalog/{$category->url}" {if !$brand->id}class="selected"{/if}>Все бренды</a>
	{foreach name=brands item=b from=$category->brands}
		{if $b->image}
		<a class="abrand" data-brand="{$b->id}" href="catalog/{$category->url}/{$b->url}"><img src="{$config->brands_images_dir}{$b->image}" alt="{$b->name|escape}"></a>
		{else}
		<a class="abrand" data-brand="{$b->id}" href="catalog/{$category->url}/{$b->url}" {if $b->id == $brand->id}class="selected"{/if}>{$b->name|escape}</a>
		{/if}
	{/foreach}
 <a class="archive" href="#"></a>
{literal}
 <script>
    var abrand = 2; // - количество отображаемых новостей
    hidenews = "Cкрыть";
    shownews = "Показать все";

    $(".archive").html( shownews );
    $(".abrand:not(:lt("+abrand+"))").hide();

    $(".archive").click(function (e){
      e.preventDefault();
      if( $(".abrand:eq("+abrand+")").is(":hidden") )
      {
        $(".abrand:hidden").show();
        $(".archive").html( hidenews );
      }
      else
      {
        $(".abrand:not(:lt("+abrand+"))").hide();
        $(".archive").html( shownews );
      }
    });
  </script>
 {/literal}
 
</div>
{/if}

Вот

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

{foreach $category->brands|@array_slice:0:10 as $b}

<a data-brand="{$b->id}" href="catalog/{$category->url}/{$b->url}" {if $b->id == $brand->id}class="selected"{/if}>{$b->name|escape}</a>
{/foreach}
{if $category->brands|count>10}<a href="catalog/{$category->url}">еще +{$category->brands|@count - 10}</a>{/if}
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...