Skip to content

Instantly share code, notes, and snippets.

@eagles038
Last active March 10, 2025 08:40
Show Gist options
  • Select an option

  • Save eagles038/fa7816184520b32d3f58b144e80bbf3a to your computer and use it in GitHub Desktop.

Select an option

Save eagles038/fa7816184520b32d3f58b144e80bbf3a to your computer and use it in GitHub Desktop.
Постраничная пагинация для разделов
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
/** @var array $arParams */
/** @var array $arResult */
/** @global CMain $APPLICATION */
/** @global CUser $USER */
/** @global CDatabase $DB */
/** @var CBitrixComponentTemplate $this */
/** @var string $templateName */
/** @var string $templateFile */
/** @var string $templateFolder */
/** @var string $componentPath */
/** @var CBitrixComponent $component */
$this->setFrameMode(true);
CPageOption::SetOptionString("main", "nav_page_in_session", "N");
$rs = new CDBResult;
$rs->InitFromArray($arResult['SECTIONS']);
$rs->NavStart(6);
if ($rs->IsNavPrint()) {
?>
<section class="section category">
<div class="container">
<div class="ui-grid category__list items-list">
<?while ($arSection = $rs->GetNext()) {
$this->AddEditAction($arSection['ID'], $arSection['EDIT_LINK'], CIBlock::GetArrayByID($arSection["IBLOCK_ID"], "SECTION_EDIT"));
$this->AddDeleteAction($arSection['ID'], $arSection['DELETE_LINK'], CIBlock::GetArrayByID($arSection["IBLOCK_ID"], "SECTION_DELETE"), array("CONFIRM" => GetMessage('CT_BCSL_ELEMENT_DELETE_CONFIRM')));
?>
<div id="<?=$this->GetEditAreaId($arSection['ID']);?>" class="ui-grid__col category__col item-content">
<a href="<?= $arSection['SECTION_PAGE_URL']; ?>" class="ui-category ui-arrowbtn-c ui-category--s1">
<div class="ui-category__inner">
<div class="ui-category__name">
<?= $arSection['NAME']; ?>
</div>
<div class="ui-category__img">
<picture>
<?if ($arSection["PICTURE"]["SRC_WEBP"]) :?>
<source type="image/webp" srcset="<?=$arSection["PICTURE"]["SRC_WEBP"]?>">
<?endif;?>
<img src="<?= $arSection['PICTURE']["SRC"]; ?>" alt="<?= $arSection['NAME']; ?>" />
</picture>
</div>
<div class="ui-category__go">
<div class="ui-arrowbtn ui-category__btn catalog__category-btn">
<span class="ui-arrowbtn__text">
В каталог
</span>
<span class="ui-arrowbtn__arr"></span>
</div>
</div>
</div>
</a>
</div>
<? } ?>
</div>
<div id="pag" class="category__more">
<?= $rs->GetPageNavStringEx($navComponentObject, '', 'more', false, null); ?>
</div>
</div>
</section>
<?
}
?>
<?
// Сколько новостей еще осталось показать
$leftItems = $arResult['NAV_RESULT']->NavRecordCount - ($arResult['NAV_RESULT']->NavPageNomer * $arResult['NAV_RESULT']->NavPageSize);
if ($leftItems > 0) { ?>
<a class="more_goods">
<span>Показать еще <?=$arResult['NAV_RESULT']->NavPageSize?>/<?=$leftItems?></span>
</a>
<? } ?>
<? if($arResult['NAV_RESULT']->NavPageCount && $arResult['NAV_RESULT']->NavPageCount != $arResult['NAV_RESULT']->NavPageNomer) { ?>
<div id="pag">
<button class="btn btn-small btn-blue btn-icon media-card-btn media-more-btn load-more-items">Загрузить еще</button>
</div>
<? } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment