douche3791 2018-09-03 09:00
浏览 48
已采纳

shopware Controller没有获得模板

i am trying to create a controller and show something on a view however it ooks like something is wrong. i created a plugin with the following files

SwagStartup/Controllers/Frontend/RoutingDemonstration.php

<?php
class Shopware_Controllers_Frontend_RoutingDemonstration extends Enlight_Controller_Action
{
    public function preDispatch(){
      $this->view->addTemplateDir(_DIR_.'/../../Resources/views');
    }

    public function indexAction()
    {
        //die('Hello world test !');
    }
}

SwagStartup/Resources/views/frontend/routing_demonstration/index.tpl

{extends file="parent:frontend/index/index.tpl"}

{block name="frontend_index_content"}
    <h1>Hello World</h1>
{/block}

i also have the config.xml,plugin.xml and SwagStartup.php in there right places.

when i uncomment the hello world i will see the text in the browser when i call the controller however when i comment it out then

Oops! An error has occurred!
We have been informed about the problem and try to solve it. Please try again within a short time.

so what could be the issue and am i missing anything? i am using shopware version 5.4.6 and following this did not help either

  • 写回答

2条回答 默认 最新

  • dongzhuo3376 2018-10-12 11:20
    关注

    Just to update incase someone gets the same issue. my problem was here, i think its because i was tired i could not see it.

    $this->view->addTemplateDir(_DIR_.'/../../Resources/views');
    

    that should have been

    $this->view->addTemplateDir(__DIR__.'/../../Resources/views');
    

    it should be __DIR__ and not _DIR_

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制