Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 14, 2015 03:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/5023088 to your computer and use it in GitHub Desktop.
Save hissy/5023088 to your computer and use it in GitHub Desktop.
[concrete5] ページリストテンプレート内で、ページの中の特定のブロックタイプのデータを取得し、そのブロックのさらに特定のデータを出力する(Designer Contentを使っている場合の例)
<?php
defined('C5_EXECUTE') or die("Access Denied.");
foreach($pages as $cobj) {
// get blocks from specific area in target page
$blocks = $cobj->getBlocks('Main');
// filter by block type handle
$_blocks = array();
foreach($blocks as $block){
if($block->btHandle == 'my_great_block_handle'){
$_blocks[] = $block;
}
}
$blocks = $_blocks;
// get instance of the block
if (is_object($blocks[0])) {
$bObj = $blocks[0]->getInstance();
// print property of the block (Designer Content style)
echo $bObj->field_1_textbox_text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment