setClasses
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 setClasses( $data )
Changes sets of classes by selector. Returns true on success.
Parameters
Parameter | Description | Version |
---|---|---|
data | Parameter passes key-value array, where key is selector and each value has two arrays specified:
Selector can be passed with position indicator (for example, .landing-block-node-text), then all cards are updated as per this selector - as well as with position indicated (for example, .landing-block-node-text@2), then updates only the card on the specified position (counting from zero). |
Example
if (\Bitrix\Main\Loader::includeModule('landing')) { \Bitrix\Landing\Landing::setEditMode(true); $landing = \Bitrix\Landing\Landing::createInstance( 5675 ); if ($landing->exist()) { foreach ($landing->getBlocks() as $block) { if ($block->getId() == 45474) { $block->setClasses([ '.landing-block-node-title@1' => [ 'classList' => [ 'landing-block-node-title', 'g-color-gray-light-v2', 'text-right' ], 'affect' => [ 'text-align' ] ] ]); $block->save(); $landing->getError()->copyError( $block->getError() ); } } } foreach ($landing->getError()->getErrors() as $error) { echo $error->getCode() . ': '; echo $error->getMessage(); echo "\n"; } }