nsmyself
nsmyself

Reputation: 3565

How can i hook a Prestashop module a the mobile template?

In Prestashop 1.5, I want to hook an existing prestashop module to the default mobile template. Can it be done using the Administration platform or do I have to tinker the classes/controllers/FrontController.php file?

Cheers

Upvotes: 0

Views: 3826

Answers (2)

Mohamed Alkaduhimi
Mohamed Alkaduhimi

Reputation: 230

For me, I solved this by overriding the FrontController class and assigning my own hook (in the example the display_left_column hook) in smarty:

<?php

class FrontController extends FrontControllerCore {

public function initContent() {
    parent::initContent();

    if ($this->context->getMobileDevice() != false) {
        $this->context->smarty->assign(array(
            'HOOK_LEFT_COLUMN' => ($this->display_column_left ? Hook::exec('displayLeftColumn') : ''),
        ));
    }

}

Then I echo'd the content of this hook in the mobile index.tpl:

<div data-role="content" id="content">
    {$HOOK_LEFT_COLUMN}

    {hook h="DisplayMobileIndex"}
    {include file='./sitemap.tpl'}
</div><!-- /content -->

Upvotes: 2

nsmyself
nsmyself

Reputation: 3565

I ended up editing the sitemap and the header templates to directly include the ones of the desired modules. It works, although it's not really "pretty", so to speak.

Upvotes: 0

Related Questions