0

我正在编写一个 prestashop 1.7 模块,并在 getContent() 方法中返回一个视图,如下所示:

public function getContent()
    {
        return $this->display(__FILE__, 'views/templates/admin/product_crawler.tpl');
    }

我的 product_crawler.tpl 文件如下所示:

<form method="POST" action="{$this->context->link->getAdminLink('ProductCrawlerGet')}">
    <input type="text" name="url">
    <input type="submit">
</form>

在 modules/product_crawler/controllers/admin 我有一个 getproducts.php 文件,如下所示:

<?php 
/**
* 
*/
class ProductCrawlerGetController extends ModuleAdminControllerCore
{

    public function postProcess()
    {
        if (Tools::isSubmit('url'))
        {
            // form processing
            return 'success';
        }
    }
}

?>

当我删除 getAdminLink() 时,它显示的表单恰到好处,但是当我向控制器添加操作时,它显示一个白页我做错了什么

4

1 回答 1

0

您必须{$link->getAdminLink('ProductCrawlerGet')}改用。

另一种选择是在 php 中的 getContent 中分配链接

$this->smarty->assign(array(
            'this_link' => $this->context->link->getAdminLink('ProductCrawlerGet'),
));

然后{$this_link}在tpl中使用

于 2017-02-26T17:08:43.660 回答