我有一个prestashop网站1.7。我想创建显示一些智能卡模板的php文件。由Dispatcher Dispatcher.php创建:
class Dispatcher extends DispatcherCore {
public function __construct(){
$this->default_routes['use-a-unique-id-here'] = [
'controller' => 'pasta', // will be linked to PastaController (see next section)
'rule' => 'my-pasta', // the actual URL without trailing slash
'keywords' => [],
];
parent::__construct();
}
}
由FrontController PastaController.php创建:
class PastaController extends FrontController {
public function initContent(){
parent::initContent();
$this->setTemplate('pasta-index');
}
}
由您的模板pasta-index.tpl创建:
{extends file='header.tpl'}
{block name='titre'}My tasty bits{/block}
{block name="breadcrumb"}{/block} <!-- will remove the breadcrumb -->
{block name='page_content'}
<h1>This is the pasta-index.tpl served by PastaController.php!</h1>
{/block}
如何创建一个PHP文件,在其中显示Smarty模板的一部分?PHP文件:
<?
require($_SERVER["DOCUMENT_ROOT"].'/config/config.inc.php');
require($_SERVER["DOCUMENT_ROOT"].'/...../PastaController.php');
class TestController extends PastaController {
public function initContent(){
parent::initContent();
$this->setTemplate('pasta-index');
}
}
echo $test;
我的代码无效!
您必须使用PrestaShop模块来完成