本文整理汇总了PHP中Mage_Core_Block_Abstract::getChildHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Block_Abstract::getChildHtml方法的具体用法?PHP Mage_Core_Block_Abstract::getChildHtml怎么用?PHP Mage_Core_Block_Abstract::getChildHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Block_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Block_Abstract::getChildHtml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetChildHtml
/**
* @covers Mage_Core_Block_Abstract::getChildHtml
* @covers Mage_Core_Block_Abstract::getChildChildHtml
*/
public function testGetChildHtml()
{
// Without layout
$this->assertEmpty($this->_block->getChildHtml());
$this->assertEmpty($this->_block->getChildHtml('block'));
// With layout
$parent = $this->_createBlockWithLayout('parent', 'parent');
$blockOne = $this->_createBlockWithLayout('block1', 'block1', 'Mage_Core_Block_Text');
$blockTwo = $this->_createBlockWithLayout('block2', 'block2', 'Mage_Core_Block_Text');
$blockOne->setText('one');
$blockTwo->setText('two');
$parent->insert($blockTwo, '-', false, 'block2');
// make block2 1st
$parent->insert($blockOne, '-', false, 'block1');
// make block1 1st
$this->assertEquals('one', $parent->getChildHtml('block1'));
$this->assertEquals('two', $parent->getChildHtml('block2'));
// Sorted will render in the designated order
$this->assertEquals('onetwo', $parent->getChildHtml('', true, true));
// GetChildChildHtml
$blockTwo->setChild('block11', $blockOne);
$this->assertEquals('one', $parent->getChildChildHtml('block2'));
$this->assertEquals('', $parent->getChildChildHtml(''));
$this->assertEquals('', $parent->getChildChildHtml('block3'));
}
示例2: testGetChildHtml
/**
* @covers Mage_Core_Block_Abstract::getChildHtml
* @covers Mage_Core_Block_Abstract::getChildChildHtml
*/
public function testGetChildHtml()
{
$blockOne = new Mage_Core_Block_Text();
$blockOne->setText('one')->setNameInLayout(uniqid('block.one.'));
$blockTwo = new Mage_Core_Block_Text();
$blockTwo->setText('two')->setNameInLayout(uniqid('block.two.'));
$this->_block->insert($blockTwo, '', false, 'block2');
// make block2 1st
$this->_block->insert($blockOne, '', false, 'block1');
// make block1 1st
$this->assertEquals('one', $this->_block->getChildHtml('block1'));
$this->assertEquals('two', $this->_block->getChildHtml('block2'));
// unsorted children will render in the order they were added
$this->assertEquals('twoone', $this->_block->getChildHtml());
// hack: rendering sorted children requires layout
$layout = new Mage_Core_Model_Layout();
$this->_block->setLayout($layout);
$blockOne->setLayout($layout);
$layout->setBlock($blockOne->getNameInLayout(), $blockOne);
$blockTwo->setLayout($layout);
$layout->setBlock($blockTwo->getNameInLayout(), $blockTwo);
// sorted will render in the designated order
$this->assertEquals('onetwo', $this->_block->getChildHtml('', true, true));
// getChildChildHtml
$blockTwo->setChild('block11', $blockOne);
$this->assertEquals('one', $this->_block->getChildChildHtml('block2'));
$this->assertEquals('', $this->_block->getChildChildHtml(''));
$this->assertEquals('', $this->_block->getChildChildHtml('block3'));
}
示例3: injectChildBlocks
/**
* Inject child blocks
*
* @param $source
* @param Mage_Core_Block_Abstract $block
* @return mixed
*/
public function injectChildBlocks($source, Mage_Core_Block_Abstract $block)
{
$count = null;
$source = preg_replace_callback('/<!--\\s*###(.+)###\\s*-->(.*)<!--\\s*###\\/\\1###\\s*-->/s', function ($matches) use($block) {
//if (Mage::getIsDeveloperMode()) {
// Mage::log('[Aoe_TemplateImport] Injecting block: ' . $matches[1]);
//}
return '<!-- BEGIN BLOCK: ' . $matches[1] . ' -->' . $block->getChildHtml($matches[1]) . '<!-- END BLOCK: ' . $matches[1] . ' -->';
}, $source, -1, $count);
//if (Mage::getIsDeveloperMode()) {
// Mage::log('[Aoe_TemplateImport] Match count: ' . $count);
//}
return $source;
}
示例4: getActionHtml
/**
* @param Mage_Core_Block_Abstract $block
* @return string
*/
public function getActionHtml($block)
{
$html = '';
$actions = $block->getChildGroup('actions');
uasort($actions, array($this, 'compareBySortOrder'));
foreach ($actions as $alias => $action) {
/* @var $action Mana_Admin_Block_Action */
$params = $action->getData();
$this->copyParam($params, 'title', 'label');
$action->setData($params);
$html .= $block->getChildHtml($alias);
}
return $html;
}