Created
February 8, 2016 15:38
-
-
Save softsolution/72b0b1e9752c374bb330 to your computer and use it in GitHub Desktop.
вывод массива (списка) по буквам по алфавиту в колонках
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{if $articles} | |
ВАРИАНТ 1 (с коррекцией) | |
<div class="well com_cont_view"> | |
<div class="row"> | |
{$cols = 6} | |
{$curcol = 1} | |
{$current = 0} | |
{$total = 0} | |
{$maxincol = ($items_count / $cols) - 3}{* 3 - для коррекции столбцов *} | |
{foreach $letters as $leter} | |
{if $curcol==1}<div class="col-md-2 col-sm-6 col-xs-6">{/if} | |
<ul class="letter-block"> | |
<li class="letter">{$leter}</li> | |
{foreach from=$articles key=ikey item=item} | |
{if $item.fletter == $leter} | |
<li><a href="{$item.seolink}">{$item.title}</a></li> | |
{$current = $current + 1} | |
{$total = $total + 1} | |
{/if} | |
{/foreach} | |
</ul> | |
{if $current < $maxincol} | |
{$curcol = $curcol + 1} | |
{if $total == $items_count}</div>{/if} | |
{else} | |
{$curcol = 1} | |
{$current = 0} | |
</div> | |
{/if} | |
{/foreach} | |
<div class="clearfix"></div> | |
</div> | |
</div> | |
<hr> | |
ВАРИАНТ 2 (по среднему) | |
<div class="well com_cont_view"> | |
<div class="row"> | |
{$cols = 6} | |
{$curcol = 0} | |
{$curitem = 0} | |
{$maxincol = $items_count / $cols} | |
{$newcol = 1} | |
{foreach $letters as $leter} | |
{if $newcol==1}<div class="col-md-2 col-sm-6 col-xs-6">{$curcol = $curcol + 1}{/if} | |
<ul class="letter-block"> | |
<li class="letter">{$leter}</li> | |
{foreach from=$articles key=ikey item=item} | |
{if $item.fletter == $leter} | |
<li><a href="{$item.url}">{$item.title}</a></li> | |
{$curitem = $curitem + 1} | |
{/if} | |
{/foreach} | |
</ul> | |
{if $curitem < $maxincol * $curcol} | |
{$newcol = 0} | |
{if $curitem == $items_count}</div>{/if} | |
{else} | |
{$newcol = 1} | |
</div> | |
{/if} | |
{/foreach} | |
</div> | |
<div class="clearfix"></div> | |
{$pagebar} | |
</div> | |
ВАРИАНТ 3 последовательно, но со сдвигом на маленьких разрешениях | |
<div class="well com_cont_view"> | |
<div class="row"> | |
{$cols = 6} | |
{$curcol = 0} | |
{$curitem = 0} | |
{$maxincol = $items_count / $cols} | |
{$newcol = 1} | |
{foreach from=$articles key=ikey item=item} | |
{if $newcol==1} | |
<div class="col-md-2 col-sm-6 col-xs-6"><ul class="letter-block">{$curcol = $curcol + 1} | |
{/if} | |
{if $item.fletter != $last_letter} | |
<li class="letter">{$item.fletter}</li> | |
{/if} | |
<li><a href="{$item.url}">{$item.title}</a></li> | |
{$last_letter = $item.fletter} | |
{$curitem = $curitem + 1} | |
{if $curitem < $maxincol * $curcol} | |
{$newcol = 0} | |
{if $curitem == $items_count}</ul></div>{/if} | |
{else} | |
{$newcol = 1} | |
</ul></div> | |
{/if} | |
{/foreach} | |
<div class="clearfix"></div> | |
</div> | |
{$pagebar} | |
</div> | |
{/if} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment