Zend_Layout 配置选项
范例
下面的例子假定使用 <?php
$options = array(
'layout' => 'foo',
'layoutPath' => '/path/to/layouts',
'contentKey' => 'CONTENT', // ignored when MVC not used
);
?><?php
/**
[layout]
layout = "foo"
layoutPath = "/path/to/layouts"
contentKey = "CONTENT"
*/
$config = new Zend_Config_Ini('/path/to/layout.ini', 'layout');
?>Example #1 传递选项给构造器或startMvc()
为了配置 首先,看一下传递数组: <?php // Using constructor: $layout = new Zend_Layout($options); // Using startMvc(): $layout = Zend_Layout::startMvc($options); ?> 现在使用配置对象: <?php
$config = new Zend_Config_Ini('/path/to/layout.ini', 'layout');
// Using constructor:
$layout = new Zend_Layout($config);
// Using startMvc():
$layout = Zend_Layout::startMvc($config);
?>
基本上,这是定制 Example #2 使用setOption() 和 setConfig()
有时候在 <?php // Using an array of options: $layout->setOptions($options); // Using a Zend_Config object: $layout->setConfig($options); ?>
然而要注意特定的选项,如 Example #3 使用访问器
最后,通过访问器来配置 <?php
$layout->setLayout('foo')
->setLayoutPath('/path/to/layouts')
->setContentKey('CONTENT');
?>
|