0
votes

I am writing a prestashop 1.7 module and I am returning a view in the getContent() method like this:

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

My product_crawler.tpl file looks like this:

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

And in modules/product_crawler/controllers/admin I have a getproducts.php file which looks like this:

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

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

?>

When I remove the getAdminLink() it shows the form just right, but when I add action to the controller it shows a white page What am I doing wrong

1

1 Answers

0
votes

You must use {$link->getAdminLink('ProductCrawlerGet')} instead.

Another alternative is to assign the link in the php, inside the getContent

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

Then use {$this_link} in the tpl