Documentation

Handling sites, scopes

Types and scopes

Site types

Sites can have the following types:

  • Main:
    • PAGE (from Home Page) - standard sites.
    • STORE - shops.
    • SMN - sites, used in Sites24 section.
  • Additional:
    • KNOWLEDGE –– knowledge bases.
    • GROUP –– knowledge bases for social network groups.

Presently, type expansion is not supported.

Scopes

In addition to a separating function, separation by permissions also exists on the level of components. Such separation is called scopes.

If you are handling with the main types, no need to do anything.
When handling additional types, indicate a scope before starting to work.

Examples

Example provides method for getting list of pages. However, underlining basis is applicable to any other method, including for entity updates and permissions. Specifying scope is valid from the moment of installation and until the page is loaded (no need to duplicate installation before each API call).

if (\Bitrix\Main\Loader::includeModule('landing'))
{
   //when scope is not indicated
   \Bitrix\Landing\Site\Type::setScope(
      'KNOWLEDGE'
   );

   // .. returns nothing, although site exists and is available to the user
   $res = \Bitrix\Landing\Landing::getList([
      'select' => [
         'ID', 'TITLE'
      ],
      'filter' => [
         'SITE_ID' => 999
      ]
   ]);
   while ($row = $res->fetch())
   {
      print_r($row);
   }
}

When on further hit, handling of another scope is planned, first you need to proceed with the following actions:
- clear the indicated scope,
- then specify a new one.
Such direct re-defining of scopes is intentional.

\Bitrix\Landing\Site\Type::setScope(
   'KNOWLEDGE'
);

// handling KNOWLEDGE in scope

\Bitrix\Landing\Site\Type::clearScope();

// after cleaning scope, once again, we have main access permissions

\Bitrix\Landing\Site\Type::setScope(
   'GROUP'
);

// now we are handling GROUP scope

© «Bitrix24», 2001-2024
Up