add
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.
public function Landing::add( $fields );
Adds a landing page.
Parameters
Class | Description | Available from version |
---|---|---|
fields | Array of landing page parameters. |
Example
if (\Bitrix\Main\Loader::includeModule('landing')) { $res = \Bitrix\Landing\Landing::add( [ 'TITLE' => 'New page', 'SITE_ID' => 1, 'CODE' => 'tratata' ] ); if ($res->isSuccess()) { echo 'new id: ' . $res->getId(); } else { print_r($res->getErrors()); } }
Using landing page template
Developer may use a template when creating site or a landing page. Template is used in site or landing page creation interface. Below is the example of how it can be done starting from the module version 18.6.0 - by querying directly the demo template component.
// connect the component and initiate it via parameters $componentName = 'bitrix:landing.demo'; $className = \CBitrixComponent::includeComponentClass($componentName); $demoCmp = new $className; $demoCmp->initComponent($componentName); $demoCmp->arParams = array( 'TYPE' => 'STORE',// PAGE – standard site, STORE – online store 'SITE_ID' => 600,//site ID 'SITE_WORK_MODE' => 'Y', 'DISABLE_REDIRECT' => 'Y' ); // get list of site demo templates $tpl = $demoCmp->getDemoSite(); // and landing pages $tpl = $demoCmp->getDemoPage(); // the array $tpl keys are template ID passed into the following method $demoCmp->actionSelect('app');
Please note, that in case of an online store, this example doesn't provide for catalog import. Also note that this code is just an example illustrating API operation.