簡體   English   中英

shopware Controller無法獲取模板

[英]shopware Controller does not get the template

我正在嘗試創建一個控制器,並在視圖上顯示某些內容,但是看起來有些錯誤。 我用以下文件創建了一個插件

SwagStartup /控制器/前端/ 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 /資源/視圖/前端/ routing_demonstration / index.tpl里

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

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

我在正確的位置也有config.xml,plugin.xml和SwagStartup.php。

當我取消注釋世界時,當我調用控制器時,我將在瀏覽器中看到文本,但是當我注釋掉時,

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

那么可能是什么問題,我有什么遺漏嗎? 我正在使用5.4.6版的購物軟件,但此操作也沒有幫助

您能否添加詳細的錯誤消息? 消息“糟糕!...”僅是用戶輸出,而不是技術錯誤消息。

https://en-community.shopware.com/Debugging-in-Shopware_detail_1912.html

我在測試插件中做了同樣的事情: https : //github.com/mnaczenski/ControllerTest/blob/master/Controllers/Frontend/Testcontroller.php

這可以正常工作並呈現插件模板。

只是為了更新,以防有人遇到相同的問題。 我的問題在這里,我想是因為我累了我看不到它。

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

應該是

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

它應該是__DIR__而不是_DIR_

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM