我想在PrestaShop 1.7中创建一个页面,但是我得到一个路径错误

时间:2017-05-26 12:49:22

标签: php templates smarty prestashop-1.7

我想在PrestaShop上创建一个页面,所以我在文件夹控制器中创建了一个文件: 的 /contollers/front/MapageController.php

然后在这个文件中插入这段代码:

class MapageControllerCore extends FrontController
{
    public $php_self = 'mapage';
    public $page_name = 'ma-page';
    public $ssl = true;
    /**
     * Initialize Ma Page controller.
     *
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        parent::initContent();
        $this->context->smarty->assign('content_only', 0);

      $this->setTemplate('costumer/mapage');
    }
}

我在costum文件夹中创建了一个 mapage.tpl 文件: 的 /主题/经典/模板/客户

当我在浏览器中查看地图时,出现此错误:

  

[PrestaShopException]

     

找不到costumer / mapage的模板   在文件类/ Smarty / TemplateFinder.php

的第68行
63.                     return $tpl;
64.                 }
65.             }
66.         }
67. 
68.         throw new PrestaShopException('No template found for '.$template);
69.     }
70. 
71.     private function getTemplateHierarchy($template, $entity, $id)
72.     {
73.         $entity = basename($entity);
  • TemplateFinderCore-> getTemplate - [第1340行 - classes / controller / FrontController.php] - [4 Arguments]
  • FrontControllerCore-> getTemplateFile - [line 1236 -
    classes / controller / FrontController.php] - [3 Arguments]
  • FrontControllerCore-> setTemplate - [第50行 -
    controllers / front / SportsHiverController.php] - [1 Arguments]
  • SportsHiverControllerCore-> initContent - [第201行 -
    类/控制器/ Controller.php这样]
  • ControllerCore-> run - [第366行 - classes / Dispatcher.php]
  • DispatcherCore-> dispatch - [第28行 - index.php]
有人可以帮帮我吗? 感谢的

1 个答案:

答案 0 :(得分:1)

$this->setTemplate('costumer/mapage'); 

在上面设置模板的代码中,你必须像这样修改代码:

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

注意:您必须在views / templates / front /

模块文件夹中创建一个mapage.tpl文件