将模块布局应用于zfcuser

将模块布局应用于zfcuser

本文介绍了将模块布局应用于zfcuser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究zf2,并尝试使用2种不同的布局.一个公共模块有一个布局,其他所有布局都有一个(私有布局),它的效果很好,但是我在公共模块中的zfcuser模块使用了另一个布局:/我尝试了这个:

i'm working on zf2 and try to use 2 differents layouts. 1 layout for a public module and another one (private layout") for all the others. Its works pretty well but my zfcuser module in the public module use the other layout :/i tried this :

'template_map' => array(
    'zfc-user/user/login' => __DIR__ . '/../view/layout/blank.phtml', // blank is my public layout
),

我不是在我的布局中获取表单,而是在公共布局和私有"布局中获取表单...有人可以帮我吗?

Instead of get the form in my layout, i get my form in the public layout AND in the "private" layout ...Does someone can help me ?

推荐答案

evan在此处提供的代码 http://blog.evan.pro/module-specific-layouts-in-zend-framework-2 将做您需要的一个小改动,将__NAMESPACE__替换为'ZfcUser',以便您正在监听ZfcUser控制器操作

The code evan provides here http://blog.evan.pro/module-specific-layouts-in-zend-framework-2 will do what you need with one minor change, replace __NAMESPACE__ with 'ZfcUser' so that you're listening for ZfcUser controller actions

public function init(ModuleManager $moduleManager)
{
        $sharedEvents = $moduleManager->getEventManager()->getSharedManager();
        $sharedEvents->attach('ZfcUser', 'dispatch', function($e) {
        // This event will only be fired when an ActionController under the ZfcUser namespace is dispatched.
        $controller = $e->getTarget();
        $controller->layout('layout/alternativelayout');
    }, 100);
}

这篇关于将模块布局应用于zfcuser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 09:17