本文整理汇总了PHP中Mage_Core_Block_Template::setChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Block_Template::setChild方法的具体用法?PHP Mage_Core_Block_Template::setChild怎么用?PHP Mage_Core_Block_Template::setChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Block_Template
的用法示例。
在下文中一共展示了Mage_Core_Block_Template::setChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manejandobloquesAction
public function manejandobloquesAction()
{
$block_1 = new Mage_Core_Block_Text();
$block_1->setText('Original Text');
$block_2 = new Mage_Core_Block_Text();
$block_2->setText('The second sentence.');
$main_block = new Mage_Core_Block_Template();
$main_block->setTemplate('nofrills/manejandobloques.phtml');
$main_block->setChild('the_first', $block_1);
$main_block->setChild('the_second', $block_2);
$block_1->setText('Wait , I want this text instead .');
echo $main_block->toHtml();
}
示例2: _createChildBlocksRecursively
/**
* @param Mage_Core_Block_Template $parent
* @param $items
*/
protected function _createChildBlocksRecursively($parent, $items)
{
foreach ($items as $key => $item) {
$block = $this->getLayout()->createBlock('manapro_filtertree/item', $parent->getNameInLayout() . '_' . $key, array('item' => $item, 'filter' => $this, 'template' => 'manapro/filtertree/item.phtml', 'show_in_filter' => $this->getShowInFilter()));
$parent->setChild($parent->getNameInLayout() . '_' . $key, $block);
$this->_createChildBlocksRecursively($block, $item->getItems());
}
}
示例3: testSetGetUnsetChild
public function testSetGetUnsetChild()
{
$layout = Mage::app()->getLayout();
$this->_block->setLayout($layout);
// regular block
$blockOne = new Mage_Core_Block_Template();
$nameOne = uniqid('block.');
$blockOne->setNameInLayout($nameOne);
$layout->setBlock($nameOne, $blockOne);
$this->_block->setChild('block1', $blockOne);
$this->assertSame($blockOne, $this->_block->getChild('block1'));
// block factory name
$blockTwo = new Mage_Core_Block_Template();
$blockTwo->setLayout($layout);
$blockTwo->setChild('block2', $nameOne);
$this->assertSame($blockOne, $blockTwo->getChild('block2'));
// anonymous block
$blockThree = new Mage_Core_Block_Template();
$blockThree->setIsAnonymous(true);
$this->_block->setChild('block3', $blockThree);
$this->assertSame($blockThree, $this->_block->getChild('block3'));
// unset
$this->_block->unsetChild('block3');
$this->assertNotSame($blockThree, $this->_block->getChild('block3'));
$this->_block->insert($blockOne, '', true, 'block1');
$this->assertContains($nameOne, $this->_block->getSortedChildren());
$this->_block->unsetChild('block1');
$this->assertNotSame($blockOne, $this->_block->getChild('block1'));
$this->assertNotContains($nameOne, $this->_block->getSortedChildren());
}