Zend framework 在Zend Framework布局脚本中使用Dojo BorderContainer
我刚刚开始在Zend框架中使用Dojo,直到最近一切都很好。现在,我希望能够使用BorderContainer和ContentPanes制作一个简单的GUI,但是我发现这有点尴尬 基本上,为了让容器Dojo元素工作,我发现需要将它们放在视图脚本中,以便Dojo工作。但是对我来说,我可以在主布局文件(layouts/scripts/default.phtml)中放置一些元素,因为单个视图脚本应该填充窗格而不是整个页面 例如,如果我将其粘贴到呈现Dojo_表单的视图中,也可以这样做:Zend framework 在Zend Framework布局脚本中使用Dojo BorderContainer,zend-framework,dojo,dijit.layout,Zend Framework,Dojo,Dijit.layout,我刚刚开始在Zend框架中使用Dojo,直到最近一切都很好。现在,我希望能够使用BorderContainer和ContentPanes制作一个简单的GUI,但是我发现这有点尴尬 基本上,为了让容器Dojo元素工作,我发现需要将它们放在视图脚本中,以便Dojo工作。但是对我来说,我可以在主布局文件(layouts/scripts/default.phtml)中放置一些元素,因为单个视图脚本应该填充窗格而不是整个页面 例如,如果我将其粘贴到呈现Dojo_表单的视图中,也可以这样做: <?ph
<?php
$this->borderContainer()->captureStart('main-container',
array('design' => 'headline'),
array(
'style'=>'height:100%;width:100%',
'align' => 'left'
));
echo $this->contentPane(
'menuPane',
'This is the menu pane',
array('region' => 'top'),
array('style' => 'background-color: gray; color:white')
);
echo $this->contentPane(
'navPane',
'This is the navigation pane',
array('region' => 'left', 'splitter' => 'true'),
array('style' => 'width: 200px; background-color: lightgray;')
);
echo $this->contentPane(
'mainPane',
$this->form,
array('region' => 'center'),
array('style' => 'background-color: white;')
);
echo $this->contentPane(
'statusPane',
'Status area',
array('region' => 'bottom'),
array('style' => 'background-color: lightgray;')
);
echo $this->borderContainer()->captureEnd('main-container');
?>
但如果我试图将任何元素放入布局中,它就会停止工作
所以,我很确定我知道为什么会这样。我认为这是因为通过在视图脚本中放置dojo视图帮助程序,dojo元素在布局脚本点击$this->dojo()之前被解析。但是,如果我将dojo元素放入布局脚本中,那么在回显$this->dojo()之后将解析这些元素
我很想看看其他人是如何解决这个问题的?只需将布局代码放在主布局文件的开头,这将强制执行工作执行顺序。因此,从定义borderContainer和ContentPanes开始,然后像这样将其余内容放在下面: $this->borderContainer()->captureStart('main-container', 数组('design'=>'headline'), 排列( '样式'=>'高度:700px;宽度:1170px', “对齐”=>“居中” )); echo$this->contentPane( “contentPaneId”, $this->render(“\u header.phtml”), 数组('region'=>'top'), 数组('style'=>'背景色:暗蓝色;颜色:白色') ); //创建更多内容窗格,并以..结束 echo$this->borderContainer()->captureEnd('main-container')
//然后,视图脚本的其余部分,包括dojo()。只需将布局代码放在主布局文件的开头,这将强制执行工作执行顺序。因此,从定义borderContainer和ContentPanes开始,然后像这样将其余内容放在下面: $this->borderContainer()->captureStart('main-container', 数组('design'=>'headline'), 排列( '样式'=>'高度:700px;宽度:1170px', “对齐”=>“居中” )); echo$this->contentPane( “contentPaneId”, $this->render(“\u header.phtml”), 数组('region'=>'top'), 数组('style'=>'背景色:暗蓝色;颜色:白色') ); //创建更多内容窗格,并以..结束 echo$this->borderContainer()->captureEnd('main-container')
//然后是视图脚本的其余部分,包括dojo()。我自己一直在尝试解决这个问题,经过几个小时的实验和@marijn答案的帮助,我终于让它工作了 首先,我使用zend工具进行了一个干净的设计。在命令行中键入:
zf create project dojoTest
cd dojoTest
zf enable layout
现在编辑layout.phtml文件,如下所示:
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body class="tundra">
<?php
$this->borderContainer()->captureStart(
'appLayout',
array('design' => 'headline'),
array()
);
echo $this->contentPane(
'headerPane',
'This is the header pane',
array('region' => 'top'),
array('style' => 'background-color: lightblue;')
);
echo $this->contentPane(
'contentPane',
$this->layout()->content,
array('region' => 'center'),
array()
);
echo $this->contentPane(
'sidePane',
'This is the sidebar pane',
array('region' => 'right'),
array('style' => 'background-color: lightblue;')
);
echo $this->contentPane(
'footerPane',
'This is the footer pane',
array('region' => 'bottom'),
array('style' => 'background-color: lightblue;')
);
echo $this->borderContainer()->captureEnd('appLayout');
?>
<?php if( $this->dojo()->isEnabled() ) { echo $this->dojo(); } ?>
</body>
</html>
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView ()
{
// Initialize view
$view = new Zend_View();
$view->doctype('HTML5');
$view->setEncoding('UTF-8');
$view->headTitle('Dojo Layout Test');
$view->headMeta()->appendName('Content-Type', 'text/html; charset=UTF-8');
$view->headMeta()->appendName('author', 'Chris OConnell');
$view->headLink()->appendStylesheet('/css/style.css?v=1', 'all');
// add dojo helper path to view
Zend_Dojo::enableView($view);
// configure Dojo view helper, disable
$view->dojo()->setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE)
->addStyleSheetModule('dijit.themes.tundra')
->setCdnVersion(1.6)
->setDjConfigOption('parseOnLoad', TRUE)
->disable();
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
// Return it, so that it can be stored by the bootstrap
return $view;
}
}
这应该可以做到
我遇到的几件事给我带来了问题:
- 无法创建dojo borderContainer
被另一个
或它所包围 不会显示。不知道为什么,但是 在试图找出答案时有很多挫折 那一个被淘汰了 height的css样式:100%代码>必须 应用于
和 borderContainer div,否则不会 展示html,body
echo$this->dojo()代码>行必须 在borderContainer语句或Zend语句之后 dojo助手将无法 生成正确的代码
zf create project dojoTest
cd dojoTest
zf enable layout
现在编辑layout.phtml文件,如下所示:
<?php echo $this->doctype(); ?>
<html lang="en">
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body class="tundra">
<?php
$this->borderContainer()->captureStart(
'appLayout',
array('design' => 'headline'),
array()
);
echo $this->contentPane(
'headerPane',
'This is the header pane',
array('region' => 'top'),
array('style' => 'background-color: lightblue;')
);
echo $this->contentPane(
'contentPane',
$this->layout()->content,
array('region' => 'center'),
array()
);
echo $this->contentPane(
'sidePane',
'This is the sidebar pane',
array('region' => 'right'),
array('style' => 'background-color: lightblue;')
);
echo $this->contentPane(
'footerPane',
'This is the footer pane',
array('region' => 'bottom'),
array('style' => 'background-color: lightblue;')
);
echo $this->borderContainer()->captureEnd('appLayout');
?>
<?php if( $this->dojo()->isEnabled() ) { echo $this->dojo(); } ?>
</body>
</html>
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView ()
{
// Initialize view
$view = new Zend_View();
$view->doctype('HTML5');
$view->setEncoding('UTF-8');
$view->headTitle('Dojo Layout Test');
$view->headMeta()->appendName('Content-Type', 'text/html; charset=UTF-8');
$view->headMeta()->appendName('author', 'Chris OConnell');
$view->headLink()->appendStylesheet('/css/style.css?v=1', 'all');
// add dojo helper path to view
Zend_Dojo::enableView($view);
// configure Dojo view helper, disable
$view->dojo()->setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE)
->addStyleSheetModule('dijit.themes.tundra')
->setCdnVersion(1.6)
->setDjConfigOption('parseOnLoad', TRUE)
->disable();
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
// Return it, so that it can be stored by the bootstrap
return $view;
}
}
这应该可以做到
我遇到的几件事给我带来了问题:
- 无法创建dojo borderContainer
被另一个
或它所包围 不会显示。不知道为什么,但是 在试图找出答案时有很多挫折 那一个被淘汰了 height的css样式:100%代码>必须 应用于
和 borderContainer div,否则不会 展示html,body
echo$this->dojo()代码>行必须 在borderContainer语句或Zend语句之后 dojo助手将无法 生成正确的代码