Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the payment controller


We will now create a front controller named Payment. But first of all, in displayPayment.tpl, set the link to the controller on the href attribute using the getModuleLink method (which we also saw in the previous chapter):

<a href="{$link->getModuleLink('mymodpayment',
'payment')|escape:'html'}" class="mymodpayment">

Next, create the payment.php file in the controllers/front/ directory of your module and fill it with a front controller that will display the payment.tpl template:

<?php
class MyModPaymentPaymentModuleFrontController extends ModuleFrontController
{
  public $ssl = true;

  public function initContent()
  {
    // Call parent init content method
    parent::initContent();

    // Set template
    $this->setTemplate('payment.tpl');
  }
}

Note

As you might have noticed, I added the public $ssl = true; variable in the preceding code. In a front controller, when the ssl variable is set to true, the SSL option is enabled in the back office...