2014-04-23 44 views
0

有沒有辦法在使用Area Splitter插件時輸出標記之前檢查subArea是否包含塊?是否可以檢查一個subArea是否包含Concrete5中的塊?

一直在嘗試這樣的東西,但不知道如何使它發揮作用遺憾:

<?php 
    defined('C5_EXECUTE') or die("Access Denied."); 
    $c = Page::getCurrentPage(); 
    $this->controller->setArea($this->area); 
?> 

<div class="box"> 
    <? if (($this->controller->subArea()->getTotalBlocksInArea($c) != 0) || ($c->isEditMode())) : ?> 
    <div class="box-header"> 
    <?php $this->controller->subArea(); ?> 
    </div> 
    <? endif; ?> 

    <? if (($this->controller->subArea()->getTotalBlocksInArea($c) != 0) || ($c->isEditMode())) : ?> 
    <div class="box-footer"> 
    <?php $this->controller->subArea(); ?> 
    </div> 
    <? endif; ?> 
</div> 

在正確的方向的任何指針將不勝感激。

乾杯

回答

0

不知道的「區域分離器」插件......我相信這是已被取代的核心本地「區域佈局」一個真正的老東西(這是我相信5.4的增加方式)。

如果你談論的是本地「區域佈局」的功能,不過,後來我在免費Page List Teasers addon,做這樣的代碼:

$aHandle = 'Main'; //<--CHANGE THIS ACCORDINGLY 
$c = Page::getCurrentPage(); 

//Get blocks inside "Area Layouts"... 
$layout_blocks = array(); 
$area = new Area($aHandle); 
$layouts = $area->getAreaLayouts($c); //returns empty array if no layouts 
foreach ($layouts as $layout) { 
    $maxCell = $layout->getMaxCellNumber(); 
    for ($i=1; $i<=$maxCell; $i++) { 
     $cellAreaHandle = $layout->getCellAreaHandle($i); 
     $cellBlocks = $c->getBlocks($cellAreaHandle); 
     $layout_blocks = array_merge($layout_blocks, $cellBlocks); 
    } 
} 

//Get non-area-layout blocks... 
$nonlayout_blocks = $c->getBlocks($aHandle); //Returns blocks in the order they're on the page 

//Combine the two sets of blocks 
$blocks = array_merge($layout_blocks, $nonlayout_blocks); 

希望你可以採取的代碼並修改它實現你想要的(例如,根據你想要的,在layout_blocks數組或者組合數組上調用count())。

相關問題