本文整理汇总了PHP中Mage_Core_Block_Abstract::setNameInLayout方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Block_Abstract::setNameInLayout方法的具体用法?PHP Mage_Core_Block_Abstract::setNameInLayout怎么用?PHP Mage_Core_Block_Abstract::setNameInLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Block_Abstract
的用法示例。
在下文中一共展示了Mage_Core_Block_Abstract::setNameInLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetGetNameInLayout
public function testSetGetNameInLayout()
{
// basic setting/getting
$this->assertEmpty($this->_block->getNameInLayout());
$name = uniqid('name');
$this->_block->setNameInLayout($name);
$this->assertEquals($name, $this->_block->getNameInLayout());
// setting second time, along with the layout
$layout = Mage::app()->getLayout();
$layout->createBlock('Mage_Core_Block_Template', $name);
$block = $layout->getBlock($name);
$this->assertInstanceOf('Mage_Core_Block_Abstract', $block);
$block->setNameInLayout($name);
$this->assertInstanceOf('Mage_Core_Block_Abstract', $layout->getBlock($name));
}
示例2: setChild
/**
* Set child block
*
* @param string $alias
* @param Mage_Core_Block_Abstract|string $block
* @return Mage_Core_Block_Abstract
*/
public function setChild($alias, $block)
{
$layout = $this->getLayout();
if (!$layout) {
return $this;
}
$thisName = $this->getNameInLayout();
if ($layout->getChildName($thisName, $alias)) {
$this->unsetChild($alias);
}
if ($block instanceof self) {
if ($block->getIsAnonymous()) {
$block->setNameInLayout($this->getNameInLayout() . '.' . $alias);
}
$block = $block->getNameInLayout();
}
$layout->setChild($thisName, $block, $alias);
return $this;
}