簡體   English   中英

Prestashop 1.7在模塊中看不到我的模板文件

[英]Prestashop 1.7 don't see my template file in module

我創建了一個名為gestionfournisseur的模塊。 我需要在此模塊中修改前端視圖的某些部分。 為此,我創建了兩個文件:

1- gestionfournisseur/controllers/front/display.php :此文件包含我的控制器邏輯和繼承模塊FrontController

<?php
class gestionfournisseurdisplayModuleFrontController extends ModuleFrontController
{
  public function initContent()
  {
    parent::initContent();
    $this->setTemplate('display.tpl');
  }
}

2- gestionfournisseur/views/templates/front/display.tpl :滿足我要顯示的視圖的需求。

Hello World!!

我在模塊主文件中使用以下指令生成了指向此頁面的鏈接:

$this->name = 'gestionfournisseur';
$this->context->link->getModuleLink($this->name,'display')

但是,prestashop給我帶來了一個很大的例外:找不到用於display.tpl的模板

如果它不能幫助您,則我的變量$ this-> context-> smarty-> getTemplateDir()的內容如下所示:

array:1 [▼
  0 => "/my_hosts/manishop/themes/classic/templates/"
]

請您告訴我有什么問題嗎?

謝謝

您需要調用setTemplate()函數,如下所示:

class SupercheckoutFcontModuleFrontController extends ModuleFrontController
{

public function initContent()
{
        parent::initContent();
                $this->setTemplate('module:supercheckout/views/templates/front/order_detail.tpl');
}

}

order_detail.tpl文件應包含以下代碼:

{extends file=$layout}
{block name='content'}
    YOUR_HTML_CONTENT_HERE
{/block}

經過一段時間和一些幫助,我找到了解決方案。

  • 首先,您需要在答案中指出@ventura show之類的模板:

    $this->setTemplate('module:supercheckout/views/templates/front/order_detail.tpl');

  • 其次,要將模板包括在布局頁面中,您需要像這樣extend page模板:

     {extends file='page.tpl'} {block name="page_content"} "trigger" {/block} 

也許這樣

  $this->setTemplate('module:supercheckout/views/templates/front/order_detail.tpl');

暫無
暫無

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

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