Last active
December 14, 2015 03:39
-
-
Save hissy/5023088 to your computer and use it in GitHub Desktop.
[concrete5] ページリストテンプレート内で、ページの中の特定のブロックタイプのデータを取得し、そのブロックのさらに特定のデータを出力する(Designer Contentを使っている場合の例)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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