A
A
Alexander Borisovich2020-09-30 07:14:03
1C-Bitrix
Alexander Borisovich, 2020-09-30 07:14:03

How to remove css styles that are inserted by Bitrix on each landing?

A very smart Bitrix inserts code that no one needs right into the page because he thinks that he needs it for some reason.

<style>
        body {
          font-weight: 400;
          font-family: "Roboto", Arial, sans-serif;
          line-height: 1.6;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
          -moz-font-feature-settings: "liga", "kern";
          text-rendering: optimizelegibility;
        }
      </style>
<style>
        h1, h2, h3, h4, h5, h6 {
          font-family: "Roboto", Arial, sans-serif;
        }
      </style>
<style>
      html {font-size: 14px;}
      body {font-size: 1rem;}
      .g-font-size-default {font-size: 1rem;}
    </style>


This code is taken exactly from the sites24 module. Landing module. Support replied that this code cannot be removed, but they will think about the tick. The code appeared after some kind of update, and the fonts on the site immediately jumped. That is, Bitrix considers it necessary for me to set the correct root font size. Bravo, huh. Throw styles in Google, you will find sites where this code is also present.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Borisovich, 2020-09-30
@Alexufo

The answer is the following. This is not in the documentation, they decided not to describe it to the end.
The code is removed by this hook. We are fraying Bitrix's desire to insert something from our topic.

$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('landing', 'onHookExec',
   function(\Bitrix\Main\Event $event)
   {
      $result = new \Bitrix\Main\Entity\EventResult;

      $result->modifyFields([ 
         'ThemeFonts' => function(/** @var \Bitrix\Landing\Hook\Page $hook */ $hook)
         {	
             \Bitrix\Landing\Manager::setPageView(
                'ThemeFonts', 
              '' 
             );


              //обязательно вернуть true, если НЕ требуется выполнение системного
            return true;
         }
      ]);

      return $result;
   }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question