B
B
Barberry2019-07-27 18:57:30
1C-Bitrix
Barberry, 2019-07-27 18:57:30

News component filter - how to filter a range of date values ​​by date type property?

Hello friends,
I activated the filter in the news component, I filter the material by the property of the date type (just a date, NOT a date and time), - the date of the events!
materials are filtered, but the date format is entered as follows: year-month-day, but not the point! The task is to filter the date range - Event date: event start date and end date ,
how to modify the component template to get a get string with a date range of approx. from 2019-08-20 to 2019-08-25, and it is desirable to display everything in inputs.
news component template code:

<?$APPLICATION->IncludeComponent(
  "bitrix:news", 
  "kalendar_meropriyatiy", 
  array(
    "ADD_ELEMENT_CHAIN" => "Y",
    "ADD_SECTIONS_CHAIN" => "Y",
    "AJAX_MODE" => "N",
    "AJAX_OPTION_ADDITIONAL" => "",
    "AJAX_OPTION_HISTORY" => "N",
    "AJAX_OPTION_JUMP" => "N",
    "AJAX_OPTION_STYLE" => "Y",
    "BROWSER_TITLE" => "NAME",
    "CACHE_FILTER" => "N",
    "CACHE_GROUPS" => "Y",
    "CACHE_TIME" => "36000000",
    "CACHE_TYPE" => "A",
    "CHECK_DATES" => "Y",
    "COMPONENT_TEMPLATE" => "kalendar_meropriyatiy",
    "DETAIL_ACTIVE_DATE_FORMAT" => "Y-m-d",
    "DETAIL_DISPLAY_BOTTOM_PAGER" => "N",
    "DETAIL_DISPLAY_TOP_PAGER" => "N",
    "DETAIL_FIELD_CODE" => array(
      0 => "",
      1 => "",
    ),
    "DETAIL_PAGER_SHOW_ALL" => "N",
    "DETAIL_PAGER_TEMPLATE" => "",
    "DETAIL_PAGER_TITLE" => "",
    "DETAIL_PROPERTY_CODE" => array(
      0 => "DATE_EVENT",
      1 => "ONMAP",
      2 => "TRANSFER",
      3 => "",
    ),
    "DETAIL_SET_CANONICAL_URL" => "N",
    "DISPLAY_BOTTOM_PAGER" => "Y",
    "DISPLAY_DATE" => "Y",
    "DISPLAY_NAME" => "Y",
    "DISPLAY_PICTURE" => "Y",
    "DISPLAY_PREVIEW_TEXT" => "Y",
    "DISPLAY_TOP_PAGER" => "N",
    "FILTER_FIELD_CODE" => array(
      0 => "",
      1 => "",
    ),
    "FILTER_NAME" => "",
    "FILTER_PROPERTY_CODE" => array(
      0 => "DATE_EVENT",
      1 => "TRANSFER",
      2 => "",
    ),
    "HIDE_LINK_WHEN_NO_DETAIL" => "N",
    "IBLOCK_ID" => "19",
    "IBLOCK_TYPE" => "calendar_events",
    "INCLUDE_IBLOCK_INTO_CHAIN" => "N",
    "LIST_ACTIVE_DATE_FORMAT" => "Y-m-d",
    "LIST_FIELD_CODE" => array(
      0 => "",
      1 => "",
    ),
    "LIST_PROPERTY_CODE" => array(
      0 => "DATE_EVENT",
      1 => "ONMAP",
      2 => "TRANSFER",
      3 => "",
    ),
    "MESSAGE_404" => "",
    "META_DESCRIPTION" => "-",
    "META_KEYWORDS" => "-",
    "NEWS_COUNT" => "20",
    "PAGER_BASE_LINK_ENABLE" => "N",
    "PAGER_DESC_NUMBERING" => "N",
    "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
    "PAGER_SHOW_ALL" => "N",
    "PAGER_SHOW_ALWAYS" => "N",
    "PAGER_TEMPLATE" => "modern",
    "PAGER_TITLE" => "",
    "PREVIEW_TRUNCATE_LEN" => "",
    "SEF_FOLDER" => "/kalendar-meropriyatiy/",
    "SEF_MODE" => "Y",
    "SET_LAST_MODIFIED" => "N",
    "SET_STATUS_404" => "N",
    "SET_TITLE" => "Y",
    "SHARE_HANDLERS" => array(
      0 => "delicious",
      1 => "facebook",
      2 => "lj",
      3 => "mailru",
      4 => "twitter",
      5 => "vk",
    ),
    "SHARE_HIDE" => "N",
    "SHARE_SHORTEN_URL_KEY" => "",
    "SHARE_SHORTEN_URL_LOGIN" => "",
    "SHARE_TEMPLATE" => "",
    "SHOW_404" => "N",
    "SORT_BY1" => "ACTIVE_FROM",
    "SORT_BY2" => "SORT",
    "SORT_ORDER1" => "DESC",
    "SORT_ORDER2" => "ASC",
    "STRICT_SECTION_CHECK" => "N",
    "USE_CATEGORIES" => "N",
    "USE_FILTER" => "Y",
    "USE_PERMISSIONS" => "N",
    "USE_RATING" => "N",
    "USE_RSS" => "N",
    "USE_SEARCH" => "N",
    "USE_SHARE" => "N",
    "SEF_URL_TEMPLATES" => array(
      "news" => "",
      "section" => "",
      "detail" => "#ELEMENT_CODE#.html",
    )
  ),
  false
);?>

filter code
<?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);
?>
<form name="<?echo $arResult["FILTER_NAME"]."_form"?>" action="<?echo $arResult["FORM_ACTION"]?>" method="get">

  <?foreach($arResult["ITEMS"] as $arItem):
    if(array_key_exists("HIDDEN", $arItem)):
      echo $arItem["INPUT"];
    endif;
  endforeach;?>
  <table class="data-table" cellspacing="0" cellpadding="2">
  <thead>
    <tr>
      <td colspan="2" align="center"><?=GetMessage("IBLOCK_FILTER_TITLE")?></td>
    </tr>
  </thead>
  <tbody>
    <?foreach($arResult["ITEMS"] as $arItem):?>
      <?if(!array_key_exists("HIDDEN", $arItem)):?>
        <tr>
          <td valign="top"><?=$arItem["NAME"]?>:</td>
          <td valign="top"><?=$arItem["INPUT"]?></td>
        </tr>
      <?endif?>
    <?endforeach;?>

  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">
        <input type="submit" name="set_filter" value="<?=GetMessage("IBLOCK_SET_FILTER")?>" /><input type="hidden" name="set_filter" value="Y" />&nbsp;&nbsp;<input type="submit" name="del_filter" value="<?=GetMessage("IBLOCK_DEL_FILTER")?>" /></td>
    </tr>
  </tfoot>
  </table>
</form>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question