D
D
DDidukh2018-03-14 17:27:31
1C-Bitrix
DDidukh, 2018-03-14 17:27:31

Bitrix - how to Implement the ability for the site administrator to specify the text in the USEFUL INFORMATION block without having to edit the source code?

[ex1-11] Text control in template: Useful information block.
• Solve the task with the help of included areas.
• Implement the ability for the site administrator to specify the text in the Useful information block without having to edit the source code.
• It should be possible to specify different text for different sections of the site.

5aa93063acc2a658153658.jpeg
• The layout that implements the "skeleton" of the block should not be in a file that contains text edited by the administrator. This will minimize the possibility
of "breakage" of the site template.
I found an answer, but I didn’t understand much:
5aa930b2e3cd8772542335.jpeg
Can you please tell me how to make a template for the included area component and do a check there?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Nikolaev, 2018-03-15
@gromdron

OMG!
Do you know how to read?? Let's talk about the task and read it.
So you need to use the bitrix:main.include component and nothing else.
You may need to write additional code.
Okay, so you don’t need to write any additional code, which means that everything can be solved with the bitrix:main.include component + template
Sections? Yeah, so we are looking at the component parameters ( https://dev.1c-bitrix.ru/user_help/components/sluz...
AREA_FILE_SHOW: sect
AREA_FILE_RECURSIVE: Y
And since bitrix:main.include includes a file in the component template, then we need to customize the component template, and not stupidly insert it
1) Place the bitrix:main.include component in the site template, configure it to work with sections
2 ) At the root we place a sect.php file in which we write "The best choice of furniture in our company!", Thus we satisfied the first decision
3) In the /company/ section we create a sect.php file in which we write "Reliable supplier for all times. "
4) After creating and placing in edit mode, click copy the component template and make changes:
- If the file does not exist or the area is empty (I hope you can do it in php) - do not display the area
- If it exists - display in the template
Read the documentation carefully ! Watch video courses .
*The exam will test YOUR knowledge, not mine*

V
Vladimir Skibin, 2018-03-14
@megafax

instead of the fact that you have useful information in the block - put a component of the included area

$APPLICATION->IncludeComponent(
      "bitrix:main.include", 
      "", 
      array(
        "AREA_FILE_SHOW" => "file", 
        "PATH" => SITE_DIR."include/info.php"
      ), 
      false
);

And in it already place the text itself. Then in the public part you will be able to edit only the included area.
"PATH" => SITE_DIR."include/info.php" - you can set at your discretion

E
Ekaterina Aristova, 2020-03-16
@Ekaterina-tr

4) After creating and placing in edit mode, click copy the component template and make changes:
- If the file does not exist or the area is empty (I hope you can do it in php) - do not display the area
- If it exists - display in the template

In the template itself:
(we check the file size and if not empty, we display the layout and file contents)
<? if (0 != filesize( $arResult["FILE"] )): ?> <!-- эта проверка необязательна, но можно использовать, если встроенной проверки компонента нет -->
<div class="side-block side-anonse">
    <div class="title-block"><span class="i i-title01"></span>Полезная информация!</div>
    <div class="item">
  <?if($arResult["FILE"] <> '')
    include($arResult["FILE"]);?>
  </div>
</div>

<? endif; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question