Jump to content

Template in module not working


Recommended Posts

Hello, I'm working on a module with similar subscription field like 'Newsletter subscription' from Prestashop devs... (ps_emailsubscription module).

Based on it I've changed logic on form submit for email and actually copied whole ps_emailsubcription.tpl into my module. Problem is that with my that copied .tpl it's not working. It lacks styles from .css, logic is corrupted as its not returning on itself after submit...

 


public function renderWidget($hookName = NULL, array $configuration = [])
{
    $this->smarty->assign($this->getWidgetVariables($hookName, $configuration));

    return $this->fetch('module:ccmodule/views/templates/hook/ccmodule.tpl');
}

public function getWidgetVariables($hookName = NULL, array $configuration = [])
{
    $variables = [];

    $variables['value']      = Tools::getValue('email', '');
    $variables['msg']        = '';
    $variables['conditions'] = Configuration::get('NW_CONDITIONS', $this->context->language->id);

    if (Tools::isSubmit('submitNewsletter')) {
        $this->registerEmail();
        if ($this->error) {
            $variables['msg']      = $this->error;
            $variables['nw_error'] = TRUE;
        } else if ($this->valid) {
            $variables['msg']      = $this->valid;
            $variables['nw_error'] = FALSE;
        }
    }

    return $variables;
}

 

Theres a code for it... the thing is, that when I write to fetch('module:ps_emailsubscription/views/templates/hook/ps_emailsubscrition.tpl'); everything is working as it should be. Dose anyone knows what I might be missing for that .tpl to get working?

Edited by gestrona (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Hi Gestrona!

 

I'm kind of having a similar issue with this module. 

The template is only rendered properly when I'm fetching a different file:

e.g.:

Changing:

    return $this->fetch('module:ccmodule/views/templates/hook/ccmodule.tpl');

to:

    return $this->fetch('module:ccmodule/views/templates/hook/ccmodule1.tpl');

 

I hope this helps somehow for your problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...