AntonLV 6 лет назад
Родитель
Сommit
b28ff83a43

+ 9 - 3
studio/classes/BxDolStudioBuilderPageQuery.php

@@ -470,10 +470,16 @@ class BxDolStudioBuilderPageQuery extends BxDolStudioPageQuery
         return $b;
     }
 
-    function resetBlocksByPage($sObject, $iCellId)
+    function resetBlocksByPage($sObject, $iCellId, $bDeactivate = false)
     {
-        $sSql = $this->prepare("UPDATE `sys_pages_blocks` SET `cell_id`=? WHERE `object`=? AND `cell_id`>?", $iCellId, $sObject, $iCellId);
-        return $this->query($sSql);
+        $aSetClause = array('cell_id' => $iCellId);
+        if($bDeactivate)
+            $aSetClause['active'] = 0;
+
+        return $this->query("UPDATE `sys_pages_blocks` SET " . $this->arrayToSQL($aSetClause) . " WHERE `object`=:object AND `cell_id`>:cell_id", array(
+            'object' => $sObject,
+            'cell_id' => $iCellId
+        ));
     }
 
     function getBlockOrderMax($sObject, $iCellId = 1)

+ 6 - 0
studio/template/scripts/BxBaseStudioBuilderPage.php

@@ -161,6 +161,12 @@ class BxBaseStudioBuilderPage extends BxDolStudioBuilderPage
 
         $sContent = "";
         if(($bPage = $this->sPage != '') === true) {
+            /**
+             * Reset and deactivate blocks which cannot be seen, 
+             * because of unsuitable cell number to currently selected layout.
+             */
+            $this->oDb->resetBlocksByPage($this->aPageRebuild['object'], $this->aPageRebuild['layout_cells_number'], true);
+
             $aTmplVars = array(
                 'page_id' => 'bx-page-' . $this->aPageRebuild['uri']
             );