本文整理汇总了PHP中Mage_Core_Model_Layout::getBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Layout::getBlock方法的具体用法?PHP Mage_Core_Model_Layout::getBlock怎么用?PHP Mage_Core_Model_Layout::getBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Layout
的用法示例。
在下文中一共展示了Mage_Core_Model_Layout::getBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLayoutObjectArgumentUpdatersDirective
public function testLayoutObjectArgumentUpdatersDirective()
{
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_arguments_object_type_updaters'));
$layout->generateXml()->generateElements();
$expectedObjectData = array(0 => 'updater call', 1 => 'updater call', 2 => 'updater call');
$expectedSimpleData = 2;
$block = $layout->getBlock('block_with_object_updater_args')->getOne();
$this->assertInstanceOf('Mage_Core_Block_Text', $block);
$this->assertEquals($expectedObjectData, $block->getUpdaterCall());
$this->assertEquals($expectedSimpleData, $layout->getBlock('block_with_object_updater_args')->getTwo());
}
示例2: getBlock
/**
* Loads a Magento layout block
*
* @param string $name Reference name of block
* @param boolean $render true: As HTML string; false: As block object
*
* @return string|Mage_Core_Block_Abstract|boolean
*/
public static function getBlock($name, $render = true)
{
/**
* @var Mage_Core_Block_Abstract $block
*/
$block = self::$layout->getBlock($name);
if ($block && $render) {
return $block->toHtml();
} else {
if ($block && $render === false) {
return $block;
}
}
return false;
}
示例3: showAddressFields
/**
* @param Mage_Core_Model_Layout
*/
protected function showAddressFields(Mage_Core_Model_Layout $layout)
{
$registerForm = $layout->getBlock('customer_form_register');
if ($registerForm instanceof Mage_Core_Block_Abstract) {
$registerForm->setShowAddressFields(true);
}
}
示例4: testGridContainsMassactionColumn
/**
* @magentoConfigFixture adminhtml/design/theme/full_name test/default
*/
public function testGridContainsMassactionColumn()
{
$this->_layout->getBlock('admin.test.grid')->toHtml();
$gridMassactionColumn = $this->_layout->getBlock('admin.test.grid')->getColumnSet()->getChildBlock('massaction');
$this->assertNotNull($gridMassactionColumn, 'Massaction column is not existed in grid column set');
$this->assertInstanceOf('Mage_Backend_Block_Widget_Grid_Column', $gridMassactionColumn, 'Massaction column is not instance of Mage_Backend_Block_Widget_Column');
}
示例5: testGetBlock
public function testGetBlock()
{
$this->assertFalse($this->_layout->getBlock('test'));
$block = new Mage_Core_Block_Text();
$this->_layout->setBlock('test', $block);
$this->assertSame($block, $this->_layout->getBlock('test'));
}
示例6: getBlockHtml
/**
* Retrieve block html
*
* @param string $name
* @return string
*/
public function getBlockHtml($name)
{
$block = $this->_layout->getBlock($name);
if ($block) {
return $block->toHtml();
}
return '';
}
示例7: testSetUnsetBlock
public function testSetUnsetBlock()
{
$expectedBlockName = 'block_' . __METHOD__;
$expectedBlock = new Mage_Core_Block_Text();
$this->_model->setBlock($expectedBlockName, $expectedBlock);
$this->assertSame($expectedBlock, $this->_model->getBlock($expectedBlockName));
$this->_model->unsetBlock($expectedBlockName);
$this->assertFalse($this->_model->getBlock($expectedBlockName));
}
示例8: getBlock
/**
* Get block
*
* @param string $blockName
* @return Mage_Core_Block_Abstract
*/
public function getBlock($blockName)
{
/** @var $layout Mage_Core_Model_Layouts */
$this->_prepareLayout();
$this->_layout->getUpdate()->load($this->_getHandles());
$this->_layout->generateXml()->generateBlocks();
$block = $this->_layout->getBlock($blockName);
$this->unsetLayout();
return $block;
}
示例9: testPrepareLayout
/**
* @magentoDataFixture Mage/Catalog/_files/product_simple.php
* @magentoAppIsolation enabled
*/
public function testPrepareLayout()
{
Mage::getConfig()->setCurrentAreaCode(Mage::helper("Mage_Backend_Helper_Data")->getAreaCode());
$product = new Mage_Catalog_Model_Product();
$product->load(1);
// fixture
Mage::register('product', $product);
$layout = new Mage_Core_Model_Layout();
$layout->addBlock('Mage_Core_Block_Text', 'head');
$block = new Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs();
$layout->addBlock($block);
$this->assertArrayHasKey(0, $block->getTabsIds());
$this->assertNotEmpty($layout->getBlock('adminhtml.catalog.product.edit.tab.attributes'));
}
示例10: testRenameElement
public function testRenameElement()
{
$blockName = 'block';
$expBlockName = 'block_renamed';
$containerName = 'container';
$expContainerName = 'container_renamed';
$block = $this->_layout->createBlock('Mage_Core_Block_Text', $blockName);
//$this->_layout->insertContainer('', $containerName);
$this->assertEquals($block, $this->_layout->getBlock($blockName));
//$this->_layout->renameElement($blockName, $expBlockName);
$this->assertEquals($block, $this->_layout->getBlock($expBlockName));
$this->_layout->hasElement($containerName);
//$this->_layout->renameElement($containerName, $expContainerName);
$this->_layout->hasElement($expContainerName);
}
示例11: _renderBlock
protected function _renderBlock()
{
$layout = new Mage_Core_Model_Layout($this->_definition['layout']);
$layout->generateBlocks();
$block = $layout->getBlock($this->_definition['block_name']);
if ($block) {
$block->setProductIds($this->_getProductIds());
$collection = $block->getItemsCollection();
// set correct order
if (is_object($collection)) {
foreach ($this->_getProductIds() as $productId) {
$item = $collection->getItemById($productId);
$collection->removeItemByKey($productId);
if ($item) {
$collection->addItem($item);
}
}
}
$html = $block->toHtml();
} else {
$html = self::EMPTY_VALUE;
}
return $html;
}
示例12: _insertBlock
/**
* Insert block
*
* @param string $blockName
* @param Mage_Core_Model_Layout $layout
*/
protected function _insertBlock($blockName, Mage_Core_Model_Layout $layout)
{
$destination = null;
switch (true) {
case $layout->getBlock('form.additional.info') instanceof Mage_Core_Block_Text_List:
$destination = $layout->getBlock('form.additional.info');
break;
case $layout->getBlock('before_body_end') instanceof Mage_Core_Block_Text_List:
$destination = $layout->getBlock('before_body_end');
break;
case $layout->getBlock('content') instanceof Mage_Core_Block_Text_List:
$destination = $layout->getBlock('content');
break;
default:
$destination = null;
break;
}
if ($destination) {
$destination->insert($blockName);
}
}
示例13: addAssets
public function addAssets(Mage_Core_Model_Layout $layout)
{
$head = $layout->getBlock('head');
$content = $layout->getBlock('content');
if ($head && $content) {
$head->addCss('webforms/form.css');
$head->addJs('prototype/window.js');
$head->addItem('js_css', 'prototype/windows/themes/default.css');
$head->addItem('js_css', 'prototype/windows/themes/alphacube.css');
// logic
$head->addJs('webforms/logic.js');
// stars
$head->addJs('webforms/stars.js');
$head->addCss('webforms/stars.css');
// tooltips
$head->addJs('webforms/HelpBalloon.js');
$head->addCss('webforms/helpballoon.css');
// wysiwyg
$head->addJs('tiny_mce/tiny_mce.js');
// calendar
$head->addJs('calendar/calendar.js');
$head->addJs('calendar/calendar-setup.js');
$head->addItem('js_css', 'calendar/calendar-blue.css');
// ajax file uploader
if (Mage::getStoreConfig('webforms/files/ajax')) {
if (Mage::getStoreConfig('webforms/files/load_jquery')) {
$head->addJs('webforms/jQuery/jquery-1.7.1.min.js');
$head->addJs('webforms/jQuery/no-conflict.js');
}
$head->addJs('webforms/blueimp/js/vendor/jquery.ui.widget.js');
$head->addJs('webforms/blueimp/js/jquery.iframe-transport.js');
$head->addJs('webforms/blueimp/js/jquery.fileupload.js');
$head->addCss('webforms/file-upload.css');
}
}
if (in_array('cms_page', $layout->getUpdate()->getHandles()) || in_array('webforms_index_index', $layout->getUpdate()->getHandles())) {
if (!$this->isProduction()) {
Mage::getSingleton('core/session')->addError($this->getNote());
}
}
// add custom assets
Mage::dispatchEvent('webforms_add_assets', array('layout' => $layout));
return $this;
}
示例14: addAssets
public function addAssets(Mage_Core_Model_Layout $layout)
{
if ($layout->getBlock('head')) {
$layout->getBlock('head')->addCss('webforms/form.css');
$layout->getBlock('head')->addCss('webforms/results.css');
$layout->getBlock('head')->addJs('prototype/window.js');
$layout->getBlock('head')->addItem('js_css', 'prototype/windows/themes/default.css');
$layout->getBlock('head')->addItem('js_css', 'prototype/windows/themes/magento.css');
}
// add custom assets
Mage::dispatchEvent('webforms_add_assets', array('layout' => $layout));
return $this;
}
示例15: testLayoutDirectives
public function testLayoutDirectives()
{
/**
* Test correct move
*/
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_move'));
$layout->generateXml()->generateElements();
$this->assertEquals('container2', $layout->getParentName('container1'));
$this->assertEquals('container1', $layout->getParentName('no.name2'));
$this->assertEquals('block_container', $layout->getParentName('no_name3'));
// verify `after` attribute
$this->assertEquals('block_container', $layout->getParentName('no_name'));
$childrenOrderArray = array_keys($layout->getChildBlocks($layout->getParentName('no_name')));
$positionAfter = array_search('child_block1', $childrenOrderArray);
$positionToVerify = array_search('no_name', $childrenOrderArray);
$this->assertEquals($positionAfter, --$positionToVerify);
// verify `before` attribute
$this->assertEquals('block_container', $layout->getParentName('no_name4'));
$childrenOrderArray = array_keys($layout->getChildBlocks($layout->getParentName('no_name4')));
$positionBefore = array_search('child_block2', $childrenOrderArray);
$positionToVerify = array_search('no_name4', $childrenOrderArray);
$this->assertEquals($positionBefore, ++$positionToVerify);
/**
* Test move with the same alias
*/
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_move_the_same_alias'));
$layout->generateXml()->generateElements();
$this->assertEquals('container1', $layout->getParentName('no_name3'));
/**
* Test move with a new alias
*/
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_move_new_alias'));
$layout->generateXml()->generateElements();
$this->assertEquals('new_alias', $layout->getElementAlias('no_name3'));
/**
* Test layout action with anonymous parent block
*/
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_action_for_anonymous_parent_block'));
$layout->generateXml()->generateElements();
$this->assertEquals('schedule_block', $layout->getParentName('test.block.insert'));
$this->assertEquals('schedule_block_1', $layout->getParentName('test.block.append'));
/**
* Test layout remove directive
*/
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_remove'));
$layout->generateXml()->generateElements();
$this->assertFalse($layout->getBlock('no_name2'));
$this->assertFalse($layout->getBlock('child_block1'));
$this->assertTrue($layout->isBlock('child_block2'));
}