Object handling
Attention! We strongly recommend first to learn more about Sites module REST documentation to understand how the module functions (with REST available in Bitrix24 Self-hosted editions). View this documentation as useful source when working with Bitrix24 Self-hosted editions and find out more details about API and only REST is not enough.
Block entity object can exist only as part of a page. That's why handling a block object can start only after page is initialized. You can find out more in the corresponding section.
Generally block handling API cannot query a specific ID and change some block field. It is up to a developer to decide, if to use this API.
Example "wrapper" code for access to block or blocks.
if (\Bitrix\Main\Loader::includeModule('landing')) { \Bitrix\Landing\Landing::setEditMode(true); $landing = \Bitrix\Landing\Landing::createInstance( 1 ); if ($landing->exist()) { foreach ($landing->getBlocks() as $block) { // directly handling the required block if ($block->getId() == 45013) { $block->setActive(false); var_dump($block->isActive()); $landing->getError()->copyError( $block->getError() ); } } } foreach ($landing->getError()->getErrors() as $error) { echo $error->getCode() . ': '; echo $error->getMessage(); echo "\n"; } }