Php 使用getAdminLink()时显示白色页面
我正在编写一个prestashop 1.7模块,并在getContent()方法中返回如下视图:Php 使用getAdminLink()时显示白色页面,php,module,prestashop,prestashop-1.7,Php,Module,Prestashop,Prestashop 1.7,我正在编写一个prestashop 1.7模块,并在getContent()方法中返回如下视图: public function getContent() { return $this->display(__FILE__, 'views/templates/admin/product_crawler.tpl'); } <form method="POST" action="{$this->context->link->getAdmi
public function getContent()
{
return $this->display(__FILE__, 'views/templates/admin/product_crawler.tpl');
}
<form method="POST" action="{$this->context->link->getAdminLink('ProductCrawlerGet')}">
<input type="text" name="url">
<input type="submit">
</form>
<?php
/**
*
*/
class ProductCrawlerGetController extends ModuleAdminControllerCore
{
public function postProcess()
{
if (Tools::isSubmit('url'))
{
// form processing
return 'success';
}
}
}
我的product_crawler.tpl文件如下所示:
public function getContent()
{
return $this->display(__FILE__, 'views/templates/admin/product_crawler.tpl');
}
<form method="POST" action="{$this->context->link->getAdminLink('ProductCrawlerGet')}">
<input type="text" name="url">
<input type="submit">
</form>
<?php
/**
*
*/
class ProductCrawlerGetController extends ModuleAdminControllerCore
{
public function postProcess()
{
if (Tools::isSubmit('url'))
{
// form processing
return 'success';
}
}
}
在modules/product\u crawler/controllers/admin中,我有一个getproducts.php文件,如下所示:
public function getContent()
{
return $this->display(__FILE__, 'views/templates/admin/product_crawler.tpl');
}
<form method="POST" action="{$this->context->link->getAdminLink('ProductCrawlerGet')}">
<input type="text" name="url">
<input type="submit">
</form>
<?php
/**
*
*/
class ProductCrawlerGetController extends ModuleAdminControllerCore
{
public function postProcess()
{
if (Tools::isSubmit('url'))
{
// form processing
return 'success';
}
}
}
当我删除getAdminLink()时,它会正确地显示表单,但当我向控制器添加操作时,它会显示一个白色页面
我做错了什么您必须改用{$link->getAdminLink('productcrawledge')}
另一种选择是在php中的getContent内分配链接
$this->smarty->assign(array(
'this_link' => $this->context->link->getAdminLink('ProductCrawlerGet'),
));
然后在tpl中使用{$this\u link}