MGP wrote
>
> luk wrote
>> Hi, setTemplate and setLayout functions change the default layout
>> template that is being used. Clearly what you're trying to achieve here
>> is to change default views path and you can easily do so by overriding
>> your template_path_stack. Try this:
>>
>> class Module
>> {
>> // ...
>>
>> public function init(ModuleManager $moduleManager)
>> {
>> $sharedEvents =
>> $moduleManager->getEventManager()->getSharedManager();
>> $sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
>> $serviceManager = $e->getApplication()->getServiceManager();
>> $templatePathResolver =
>> $serviceManager->get('Zend\View\Resolver\TemplatePathStack');
>> $templatePathResolver->setPaths(array(__DIR__ .
>> '/view/blue')); // here is your skin name
>>
>> }, 100);
>> }
>> }
> Doing that, for some reason, breaks the code. It causes: Unable to render
> template "application/index/index";
> It always try to load the default view (in the default dir) for that
> module/controller/action, even if you remove that path from the stack. (I
> still cant understand why...)
>
> Instead of using setPaths, can you just add a new path to the stack?
> (using the ->addPath(__DIR__ . '/view/blue')
You can use addPath method, it works as well. Your error may be related to
some routes configuration being overriden. Just to test it please try to
create a separate module with new route instead of the Application one. Then
use that template stuff switch in the same way. For me it works fine.
-----
Cheers,
--
Luke Mierzwa
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-How-to-change-template-directory-tp4656995p4657298.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]