L
L
leracoder2020-12-21 19:27:15
1C-Bitrix
leracoder, 2020-12-21 19:27:15

How to make the same header and footer for all site templates?

There are 3 templates on the site, how to implement so that for all templates the header and footer of the site are displayed the same (+ the header and footer have their own styles)?
(so you don't have to go into each template and edit the header in it..)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2020-12-21
Madzhugin @Suntechnic

I make a general .default template, and in the rest of the templates in the header:

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();?>
<?include(S_P_LAYOUT.'/header.php');?>
<div class="page">
  <!-- HEADER :: START-->
  <header class="header">
    <div class="container">
      <div class="header__wrapper">
        <a class="header__logo" href="#"><img src="<?=P_IMAGES?>/logotype.svg" alt=""></a>
        
        <?include(S_P_INCLUDES.'/menu-top.php');?>
        
        <div class="header__links">
          <?include(S_P_INCLUDES.'/menu-links.php');?>
        </div>
        
        <button class="hamburger hamburger--spin" type="button" js-hamburger><span class="hamburger-box"><span class="hamburger-inner"></span></span></button>
      </div>
    </div>
  </header>
  <!-- HEADER :: END-->
  <div class="page__content">
    <?$APPLICATION->ShowPanel()?>

and similarly in the footer:
какой-то отличающийся код
<?include(S_P_LAYOUT.'/footer.php');?>

Accordingly, S_P_LAYOUT is a constant with an absolute path to the template folder. .default
This is the number one option (and generally speaking, you can nest as many templates as you like).
The second option is to use common include areas across all templates.

N
N, 2020-12-21
@Fernus

https://dev.1c-bitrix.ru/learning/course/index.php...

A
Anton, 2020-12-21
@anton99zel

Well, set one template for all sites)
Or use symlinks (as with multi-site)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question