Model view controller 如何强制Phalcon从另一个模块而不是定义的模块中选择视图?

Model view controller 如何强制Phalcon从另一个模块而不是定义的模块中选择视图?,model-view-controller,phalcon,dispatcher,phalcon-orm,Model View Controller,Phalcon,Dispatcher,Phalcon Orm,目前,我正在加载URL/Route/admin/config/users上的所有用户,它从管理模块中选择此视图(private/apps/admin/Views/user/users.volt) 现在我已经为自定义布局设置了一个标志。因此,如果启用了自定义布局,我希望phalcon从AdminExtension模块中选择视图,即(private/apps/Admin/Extension/Views/user/users.volt) 我怎样才能做到这一点?我想要两种观点。因为private/app

目前,我正在加载URL/Route
/admin/config/users
上的所有用户,它从管理模块中选择此视图(
private/apps/admin/Views/user/users.volt

现在我已经为自定义布局设置了一个标志。因此,如果启用了自定义布局,我希望phalcon从AdminExtension模块中选择视图,即(
private/apps/Admin/Extension/Views/user/users.volt

我怎样才能做到这一点?我想要两种观点。因为
private/apps/Admin/Views/user/users.volt
是列出所有用户的默认视图。然而,
private/apps/Admin/Extension/Views/user/users.volt
是为客户定制的视图,在那里进行了大量的设计更改

以下是dispatcher代码的外观:

/**
 * @param Dispatcher $dispatcher
 */
public function afterExecuteRoute(Dispatcher $dispatcher) {

    // Check if Json response is required
    if ($this->_isJsonResponse) {
         //if body
    } else {

        if(CxSettingCustomLayout::loadFromDb()->isCustomLayout()) {
            //pick custom view here" `private/apps/Admin/Extension/Views/user/users.volt`
        }

        // Build current module configuration settings section name
        $moduleConfigName = 'app_' . $this->dispatcher->getModuleName();
        // Include assets configuration file where assets collections are defined
        if(file_exists($this->config[ $moduleConfigName ]['assetsFile']))
            include $this->config[ $moduleConfigName ]['assetsFile'];

        // Set a view variable with the current language code
        $this->view->setVar('current_language_code', $this->CxTranslation->getLanguage()->getCode());
    }
}

正如@num8er已经说过的,尝试使用
setViewsDir
。我使用Phalcons
Simple
view类的方式如下

use Phalcon\Mvc\View\Simple;

$view = new Simple();
$view->setViewsDir(BASE_PATH . '/app/views/');
echo $view->render('admin/users');

你想要这个
$this->view->render
或检查要使用的方法:同时检查
setViewsDir
setLayoutsDir
阅读手册: