Jump to content

Error, warning and success messages


Recommended Posts

I am creating a module and need to show error, warning and success messages on the configuration page.


I have seen code like this in other modules:

$this->warnings[] = $this->l('Warning...');
$this->context->smarty->assign('form_infos', $this->warnings);

... but i can't seem to make it work.


Is there a way to add messages to an array as text strings and have them rendered using the default error, warning and success prestashop templates?

Link to comment
Share on other sites

Maybe have a look in a file like 



in function:

  public function getContent()
Where they use calls to functions (defined in classes/module/Module.php)
  $this->_html .= $this->displayError($this->l('Bad URL'));
  $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
Have a look.
My 2 cents,
  • Like 1
Link to comment
Share on other sites

Thanks Pascal, that's very helpful.


I managed to find the last bit I was looking for on my own. By adding...

$this->warning = $this->l('Bad configuration.');

...to the __contruct method a warning is shown whenever the modules admin page is opened.

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...