Zend framework and Ext-Js4, file and folder structure

僤鯓⒐⒋嵵緔 提交于 2019-12-25 01:24:37

问题


I am trying to use Zend Frame work and Ext-Js4 together.

But I don't know how to setup file and folder structure correctly.

I setup like this,

And in application/controllers/IndexController.php

$this->view->headScript()->appendFile('/js/ext-4.0.7/ext-all.js','text/javascript');
$this->view->headScript()->appendFile('/js/app.js','text/javascript');
$this->view->headLink()->appendStylesheet('/js/ext-4.0.7/resources/css/ext-all.css');

Is it right structure? anyone has a better idea?

Thank you.


回答1:


If you're using Ext-Js4 in your entire application, a better idea would be to add this in your bootstap, so that you don't have to include your javascript paths in every controllers.

protected function _initView()
{
    $view = new Zend_View();
    $view->headScript()->appendFile('/js/ext-4.0.7/ext-all.js','text/javascript');
    $view->headScript()->appendFile('/js/app.js','text/javascript');
    $view->headLink()->appendStylesheet('/js/ext-4.0.7/resources/css/ext-all.css');
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);
    return $view;
}



回答2:


I tend to use a layout for things like this:

function _initViewHelpers()
{
    $this->bootstrap('layout');
    $layout = $this->getResource('layout');
    $view = $layout->getView();

    $view->doctype('HTML4_STRICT');
    $view->headMeta()->appendHttpEquiv('Content-type', 'text/html;charset=utf-8')
                     ->appendName('description', 'My App');

    $view->headTitle()->setSeparator(' - ')
                      ->headTitle('My App');
}

Then in my application.ini file I include:

resources.view[] =
resources.layout.layoutPath = APPLICATION_PATH "/layouts

There are always more ways to skin the proverbial cat!



来源:https://stackoverflow.com/questions/9396873/zend-framework-and-ext-js4-file-and-folder-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!